Keep the editor's code clear of Jim's stage
Jim's stage floats over the editor, and the editor did not know it was there. At 1366x900 the end of a line longer than about 95 columns, and the caret typing there, scrolled to the textarea's right edge at x 1349, under the stage that starts at x 1174; at 1100x800 the last rows could not be scrolled out from under the compact card. As accepted in #512, this keeps the floating stage, the captions, the self-view and the shell layout as they are and changes only the editor's scroll range.
placeJimStageBelowToolbar() already observes the stage. It now also passes the stage, measured after .scrollable is settled, to reserveJimStageInEditor(), and observes the editor stack, since the test drawer's splitter moves the editor under the card without resizing the window or the stage. reserveJimStageInEditor() writes one of two reservations to the editor stack, whichever costs the editor less: --jim-stage-reserve-right, the width beside the stage plus a 6 px gap, or --jim-stage-reserve-bottom, the overlap of a compact card at the bottom.
Beside the stage the reservation is a transparent right border on #editor and #editor-highlight, not the right padding #512 proposed. Chromium leaves a textarea's right padding out of its scroll range: with 191 px of right padding the end of a long line still scrolled to x 1349.6. A narrower box would scroll correctly but leaves the strip beside the code outside the textarea, so a click there blurred the editor; a border still takes that click. In forced colors the border is Canvas: a transparent border is forced to CanvasText and painted the whole strip black, while a system color the author sets is kept, so the text and token colors stay forced. Under a compact card both text layers and the gutter pad their bottom instead, and scroll-padding-bottom keeps the caret above the card while typing, because the card grows with the captions and a border there would resize the text area while Jim speaks.
The bottom overlap is measured at rest, editor.bottom + window.scrollY + panel.scrollTop - stage.top, as the toolbar anchor is: scrolling only moves the editor up from under the fixed card, so the overlap at rest is the most it can be and the reserve does not depend on where the page or the panel is scrolled. The right reserve reads only horizontal positions. Comparing the two fractions keeps the cheap bottom reserve for the usual compact card (14 px of a 512 px editor at 1100x800, against 39% of its width) and takes the width when a long caption and the self-view grow the card down most of the editor (98% of its height at 1100x600). Below 1024 px the sidebar stacks above the editor and the page scrolls; the right reserve now covers those widths as well (1023x700, 1000x700, 900x800 and 800x900 all left the row beside the card under it before). A card over half the editor's width, as on a phone, never takes the width: it keeps the bottom only where that is the cheaper side.
The three points raised in #512:
- The test drawer. This change reserves space in the editor only; the right side of Add a case and Test results under the compact card is left for #790.
- The right reservation is written once for the whole editor, so rows below the floating stage also end at the stage's column and leave an empty strip under it. "Placement and pose" in
docs/avatar-contract.mdnow says so. - The caret test.
at <width>x<height> the caret at the end of a long line scrolls clear of Jim's stageruns at 1920x1080, 1366x900 and 1100x800, and at 1100x600 with a tall card, 1100x520 with a resize while the page is scrolled, and 1000x700. It types a 302-character line, presses Home to check that the line is longer than the editor, presses End so the browser scrolls to it, then checks that the last glyph painted on#editor-highlightdoes not overlap the stage and that#editor, which holds the caret, and#editor-linesscrolled exactly as far. At 1100 the stage is the compact card, so the row may end above it rather than left of it, which is what the bottom reservation provides. At 1000x700 the row is edited three rows above the end, where the browser has no reason to scroll the page; as the last row it would be scrolled into the 24 px below the card and pass without the change. With thereserveJimStageInEditor()call removed the test fails at all six sizes; at the three #512 asked for, the line ends at 1903.6 under the stage from 1728 at 1920, at 1349.6 under the stage from 1174 at 1366, and the last row ends at 658.2 under the card from 606.6 at 1100x800.
the strip beside Jim's floating stage takes a click and stays blank in forced colors pins the click and the forced-colors border, and on a phone the card across the editor reserves none of its width pins the half-width limit. Removing the border, the forced-colors rule, scroll-padding-bottom, the gutter's bottom padding, the editor-stack observer, the scroll offsets or the cost comparison each fails one of these tests. Reading the stage before .scrollable is settled fails none: the stage becomes scrollable only when it is taller than the window, which also makes the page scroll, and the right reserve reads only stage.left, which .scrollable does not move.
Before and after at 1366x900 and 1100x800, on the test page with a long line as the caret's row:
./scripts/test.sh at this head, with Git 2.56.1: every gate passes except two that fail on this machine for reasons outside the change. git-hooks fails 2 of 482 checks because shfmt, commentflow and ruff are not installed; browser-tests fails only a formatter that cannot load changes nothing, and the next press loads it in tests/browser/format-shortcut.test.js, which fails the same way with this change reverted and passes on main in CI. Not run here: Java, ffmpeg and desktop tests, and the formatters and linters listed above. Not checked: Firefox and Safari, whose caret reveal may ignore scroll-padding-bottom (the last rows stay reachable by scrolling either way), and a live interview with captions growing the card. On a phone, where the width is never reserved and the bottom rarely is, the browser's caret reveal does not know about the fixed card, so the caret can sit under it while typing until the page is scrolled.
#713 also changes placeJimStageBelowToolbar(), returning place and changing its scrollable condition, so whichever of the two lands second rebases.
Close #512
Summary by cubic
Keeps the editor's scroll range clear of Jim's stage, so the caret and the end of a long line no longer scroll under it. This only changes the editor's scroll range; the floating stage, captions, self-view, and shell layout stay as accepted in #512.
- Reserves whichever side costs the editor less: the width beside the floating stage, or the bottom rows under the compact card.
- Beside the stage, a transparent right border reserves the width with a 6 px gap; a textarea's right padding doesn't affect its scroll range, and a narrower box wouldn't take a click beside the code. In forced colors the border uses the
Canvassystem color so it doesn't paint as a solid bar. - Under the compact card, the text layers and gutter pad their bottom and
scroll-padding-bottomkeeps the caret above the card while it grows with the captions. - An editor-stack observer updates the reservation when the test drawer's splitter moves the editor. A card over half the editor's width, as on a phone, reserves nothing.
- Caret tests run at 1920, 1366, 1100, and 1000 px widths, covering a growing caption bar, a resize while scrolled, the stacked sidebar, and a phone-width test, plus a click-and-forced-colors test on the reserved strip.
Closes #512.