Repository navigation
fix(editor): keep the caret in view after Cmd+Up, Cmd+Down and paste - #3242
Merged
Merged
Conversation
SourceEditor compared its state binding with the editor's live values. The editor writes scroll and find state back a run-loop turn late, so a layout pass in between pushed the old scroll position back. State fields are now diffed against the value the coordinator last synced. State writes no longer set the text-sync latch, which an unchanged cursor write left set, dropping the host's next text change. SQLEditorView drops the focus guard that worked around the stale push, so Run, Explain and AI use the caret after find navigation. Fixes #3239
Autocomplete UI tests on CI committed the wrong keyword after the last typed character, which points at a state push in the update pass right after a caret write. The latch skipped that pass before this branch. Changed state writes set it again, and only an unchanged write, which runs no update pass to clear it, leaves it alone.
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.
Why
In a long query, Cmd+Up, Cmd+Down and long pastes moved the caret but not the view. The editor did scroll, then its SwiftUI wrapper scrolled it back: it compared the binding with the editor's live scroll position, which the editor writes back a run-loop turn late, so a layout pass in between read the old value as a request to return to it.
Change
Verified
SourceEditorStateSyncTests(6 of 7 fail on main) andSQLEditorCursorPropagationTests(fails on main). Each flow checked on a Debug build.Screenshots
Not in this PR
FindPanelViewModel+Replace.swift:85), and matches go stale after the document is replaced. Separate causes, left for a follow-up.Fixes #3239