Remember scroll position per document across switches#70
Merged
Conversation
The editor reset scroll to the top on every document switch. Now each document's scroll offset (clip-view bounds.origin.y) is captured when switching away and restored when shown again, clamped to the new content height so a shorter document never lands in empty space. Embedders can scope retention via the new optional 'retainedScrollDocumentIds': offsets for documents not in the set are forgotten (default nil keeps all). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
After a Writing Tools (Proofread/Rewrite/Compose) session, didEnd pre-set lastSyncedText == text, so updateNSView early-returned and never re-styled or re-measured the accepted result — it stayed unstyled, and a taller result overflowed the stale frame and wasn't visible. Don't pre-set lastSyncedText; let the normal updateNSView rebuild handle it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
luca-chen198
added a commit
that referenced
this pull request
Jun 20, 2026
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.
What
The editor reset scroll to the top on every document switch. This adds per-document scroll memory: each document's vertical offset is captured when switching away and restored when it's shown again.
How
NativeTextViewCoordinator.scrollOffsets: [documentId: CGFloat]holds the offsets (survives switches — same coordinator instance).updateNSView: capture the outgoing document'sbounds.origin.y, park at the top during the content rebuild, then restore the incoming document's saved offset once its height is measured.clampToInsets()keeps it in range, so a shorter document never lands in empty space.retainedScrollDocumentIds: Set<String>?lets embedders scope retention — offsets for documents not in the set are forgotten (defaultnilkeeps all). The Nodes app uses it to forget a node's scroll once it leaves the open-items list.Notes
nil.🤖 Generated with Claude Code