Repository navigation
fix(docx): what the reader does while Find or the outline is on its way comes first - #60
Open
pierreneter wants to merge 1 commit into
Open
pierreneter wants to merge 1 commit into
pierreneter wants to merge 1 commit into
Conversation
…ay comes first Find and the outline scroll to their target and select it once the scroll has come to rest, some frames later. Nothing stopped that late selection: a reader who pressed Enter in Find, then clicked into the text and typed, could have the match selected again after the click, and the keys typed replaced the word found. - A click, a key or the wheel in the document drops the jump on its way, and so does a newer jump. - At its end, the jump selects its target only while the document's selection is where it was when the jump began (or not in the document): one set since, by the reader or by the host through the DOM, is kept. - No selection is put in a paragraph edited meanwhile: the match's offsets are out of date. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
Find and the outline scroll to their target, then select it once the scroll has come to rest:
afterScrollruns a few frames later, up to 120 on a slow machine. Nothing stopped that late selection, so it could land after the reader had already put the caret somewhere else.What went wrong
A reader presses Enter in Find, then clicks into the text and types. If the late selection came after the click, the match was selected again and the keys typed replaced the word found. Without Track changes on, the word was gone without a trace. The outline did the same: its late caret took the place of the one just clicked.
This is the cause behind the flaky
e2e/plain.spec.tsin #59, which only makes that test wait for the selection.Fix (
src/react/docx/DocxView.tsx).de-scrolldrops the jump on its way, and so does a newer jump. EachafterScrolltakes a number, and a jump runs only while its number is still the latest. The Find bar is outside.de-scroll, so its own keys (Enter for the next match) don't drop anything.Closing the Find bar alone doesn't drop the jump: Enter then Escape still leaves the match selected, as when the frames come on time.
Tests
e2e/docx-jump.spec.ts(new), with every animation frame made 1 s late:NEIGHBOR, typeXYalpha XY omegaselectText)alpha XY omegabun test ./test: 1751 pass, 0 failtsc --noEmit: cleanbun test ./e2e: 381 pass, 13 fail on macOS (CI runs Linux):dist/for the four*-builtspecs (bun run build), and the generatedlarge-deck.pptx;mainon this machine (Mac key bindings:Control+c,End,Tabin a slide);plain.spec.ts(the known flaky one) failed once in the full run, while a source file was saved during it. It passed in the two runs that comparedmainwith the fix, and 3 out of 3 times withdocx-jump.spec.ts.🤖 Generated with Claude Code