Fix editor jumping when typing at end of long documents#288
Merged
Conversation
When typing at the end of a long document, the editor would jump to the middle of the document because editorBoundsDidChange: triggered syncScrollers on every keystroke. The sync algorithm recalculated scroll position based on header reference points, and as content grew, headers crossed the filtering threshold causing reference points to change. This fix adds an inEditing flag that prevents scroll synchronization during active typing. A delayed sync (200ms) runs after editing pauses, allowing the layout to stabilize before syncing. Changes: - Add inEditing property to track editing state - Modify editorBoundsDidChange: to skip sync when inEditing is YES - Add performDelayedSyncScrollers method for delayed sync after typing - Modify editorTextDidChange: to set inEditing and schedule delayed sync - Add tests for the new editing state behavior Related to #282
Cancel pending performDelayedSyncScrollers in the close method to prevent crash if document is closed within 200ms of last keystroke. Without this, the delayed selector could fire on a deallocated object. Also adds test for close cleanup behavior. Related to #282
Update MPScrollSyncTests documentation to include the 8 new tests added for editing-state-aware scroll sync behavior. Related to #282
Contributor
Code Coverage ReportCurrent Coverage: 52.80% Coverage Details (Summary) |
schuyler
pushed a commit
that referenced
this pull request
Jan 24, 2026
Comprehensive testing plan covering all changes since v3000.0.3: - Smart quote substitution fix (#289) - Editor jumping when typing at end of long documents (#288) - New document window positioning (#286) - Graphviz/Mermaid button positioning in Compilation Settings (#280) - Adjacent shortcut-style links rendering (#275) Includes regression testing checklist for core functionality.
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.
Summary
Fixes an issue where the editor would jump to the middle of the document when typing at the end of a long document.
Root cause: The
editorBoundsDidChange:handler triggeredsyncScrollerson every keystroke because content height changes. The sync algorithm recalculated scroll position based on header reference points, and as content grew, headers crossed the filtering threshold causing reference points to change and the editor to jump.Solution: Add an
inEditingflag that prevents scroll synchronization during active typing. A delayed sync (200ms) runs after editing pauses, allowing the layout to stabilize before syncing. This follows the existinginLiveScrollpattern.Changes
inEditingproperty to track active editing stateeditorBoundsDidChange:to skip sync wheninEditingis YESperformDelayedSyncScrollersmethod for delayed sync after typing pauseseditorTextDidChange:to setinEditingand schedule delayed syncclosemethod to cancel pending delayed sync (prevents crash)Related Issue
Related to #282
Manual Testing Plan
Key Test Scenarios
Primary Bug Fix - Typing at End of Long Document
Continuous Typing Behavior
Document Close During Editing
Live Scroll Still Works
Sync Disabled
Edge Cases