Repository navigation
Fix the cursor, the selection and the preview in a presentation's editor - #424
Merged
Merged
Conversation
In a presentation's slide mode each open row is a CodeMirror of its own,
and every change of a row's selection is sent on to the editor's own
CodeMirror, the master, which is hidden. The row sent a click's selection
on marked as a click's ("select.pointer"). CodeMirror writes the page's
selection into any view told of a click's selection, focused or not, so
the hidden master took the page's selection away from the row: the row
kept the focus but drew no caret, a double click's word and a dragged
selection were not drawn, and the master then read its own selection
back and moved the row's cursor, so that a click in a row without the
focus left its cursor at the row's start and a key typed went elsewhere.
An arrow key drew the caret again because the row then wrote the page's
selection itself.
The row now sends a click's selection on as a plain "select". The
browser tests click in a row's text with the driver's pointer, and
double-click and drag with mouse events, in a row, in a document's editor
and in a presentation's raw Markdown; the last two never had the fault.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
The editor's preview of a presentation scales each slide's card to the width inside the pane, measured whenever the pane changes size (wiki-app/jsbits/slide-fit.js). That width depended on the pane's scrollbar, and the scrollbar on the cards' height. At the threshold, a slide with notes just as tall as the pane, the scrollbar came, the card was scaled down and no longer overflowed, the scrollbar went, the card was scaled up and overflowed again: the slide changed size at every frame, about 60 measures a second with nobody doing anything. The pane now keeps the scrollbar's room whether it scrolls or not (scrollbar-gutter: stable), so the width the cards are scaled to no longer depends on what the scale changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
Swordlash
pushed a commit
that referenced
this pull request
Dec 2, 2026
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
Swordlash
force-pushed
the
slide-row-cursor
branch
from
December 2, 2026 23:12
9a47f69 to
2516115
Compare
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WP5.145, the first two of three faults of a presentation's editor the owner reported, each with its own cause and its own commit. The third (the preview following the cursor) was in this pull request at first and is cut off into the next one, stacked on this branch, after the first review round found six things in it and none in these two.
1. The cursor and the selection in a slide's row
Cause. A row's transaction is sent on to the hidden master editor (
forwardedinweb/src/editor.js), and it copied the user eventselect.pointer. CodeMirror writes the page's selection into any view told of a pointer selection, even one without the focus, so the hidden master took the page's selection away from the row, then read its own selection back and moved the row's cursor. It has been so since the rows were written (2026-11-12); it is not from the library's pin. Fix: a click's selection is forwarded to the master as a plainselect.What a real click did before: in a row that had the focus, the selection was right in CodeMirror but the page's selection sat in the hidden master, the caret had a box of 0×0 and a key typed went elsewhere; a click in another open row drew the caret at the row's start; a double click selected a word that was not drawn; a drag drew nothing and ended at the wrong place.
A document's editor and a presentation's raw text had neither fault.
2. The preview that never came to rest
Cause, a loop of two halves.
wikiFitMeasure(wiki-app/jsbits/slide-fit.js) sets a card's scale from the preview's inner width and is run again by aResizeObserver; the side-by-side pane has a fixed height andoverflow-y: auto, and a card's height follows its scale. At the threshold the scrollbar comes, the card shrinks, the scrollbar goes, the card grows. Measured at a window of 1800×830 to 842 with classic scrollbars: the scale flipped between 0.6748 and 0.6602, 58 to 60 times a second. Fix:scrollbar-gutter: stableon that pane, so the measure does not depend on what it changes. Idle afterwards: 0 measures, 0 changes of scale, 0 mutations. The loop never reached the editor's renders (its messages were deduplicated), so it did not cause the first fault.Known and left
scrollbar-guttercomes with the next pull request, where its helper was written.Tests
Verification
Run locally, on the three-fault head this was cut from:
build-native,build-wasm,format-check,lint; the browser groups "A presentation in the editor", "Room to write in" and "A presentation embedded in a page" (97 examples). This head is its first two commits; CI is its gate. The other browser suites and the smoke suites are left to CI.Codex
Round 1 (9a47f69, gpt-6.2-sol, high, on the head with all three faults): six findings, five in the following of the cursor and one that the scrollbar's fix is not exercised by its test (said above); none in the cursor and selection's fix. The following is cut off into the next pull request, where the five are fixed; this one is its first two commits (2516115).
Round 2 (2516115, which differs from the head after it only in the changelog entry's title; that title was 89 bytes where 80 are allowed and failed CI's build of "What's new", and is shortened in cd64a47): two findings. Being fixed: a click's selection and an arrow key's now both carry the event
select, so the history joins them and Undo Selection after a key and a quick click skips the place between; the click gets an event of its own that is neither a pointer's to the hidden master nor a key's to the history. Left as said above: no test closes the scrollbar's loop in the suite's browser.(rounds are added here)
🤖 Generated with Claude Code
https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM