Repository navigation
markdown: stop snapping the editor back to the preview scroll position - #350010
Merged
Merged
Conversation
`getPreviousStaticEditorLineByUri` kept the preview's last scroll line, so every later activation of the markdown text editor scrolled it back to that line, overwriting where the user had scrolled. Consume the line on read, like `getPreviousTextEditorLineByUri` does for the other direction, so the preview to editor handoff happens once. Fixes #317033
Brings sundarshahi's commit from #345112 up to date with main, unchanged, so that it can go through the merge queue from a branch of microsoft/vscode. 🤖 Authored with GitHub Copilot on behalf of @alexdima. Co-authored-by: Copilot <[email protected]>
SteVen Batten (sbatten)
approved these changes
Nov 23, 2026
Alexandru Dima (alexdima)
enabled auto-merge
November 23, 2026 23:00
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the scroll-position handoff fix, though the build and Markdown extension tests were not run locally.
No open issues 🎉
What changed in this PR
Fixes repeated Markdown editor scroll resets by restoring the one-time handoff of the preview’s scroll position to the text editor.
Changes:
- Removes the stored preview line after it is retrieved, preventing later tab switches from reapplying it.
- Adds a regression test verifying that the stored line is returned once, then
undefined.
No actionable findings remain. The build and Markdown extension tests were not run locally.
| File | Description |
|---|---|
extensions/markdown-language-features/src/test/topmostLineMonitor.test.ts |
Tests one-time retrieval of the preview scroll position. |
extensions/markdown-language-features/src/preview/topmostLineMonitor.ts |
Clears the stored preview position after retrieval. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 23, 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.
Fixes #317033. Replacement for #345112. This preserves Sundar Shahi Thakuri (@sundarshahi)'s original commit and adds only a signed merge commit that brings it up to date with
main.Summary
Since 1.120, once the Markdown preview of a file has been scrolled, every later switch back to that file's text editor scrolls the editor to the preview's last position, until the window is reloaded. #315425 made
TopmostLineMonitor.getPreviousStaticEditorLineByUristop removing the stored preview line, so the one-time handoff from the preview to the text editor was replayed every time the text editor became active.getPreviousStaticEditorLineByUriremoves the entry it returns again, likegetPreviousTextEditorLineByUri.topmostLineMonitor.tsis identical to its version before Various improvements and fixes for markdown diff rendering #315425.Known limit, described in #345112: while the preview editor stays open beside the text editor, scrolling the preview can still move the text editor once, the next time the text editor becomes active.
How to test
Validation
git diff origin/main...HEAD | git patch-id --stableandgit show 2c785ffbcf2 | git patch-id --stableprint the same patch ID (6f22a2fb574): this pull request changes exactly what markdown: stop snapping the editor back to the preview scroll position #345112 changes.git diff --check origin/main...HEAD: passed.topmostLineMonitor.test.ts. CI runs them.🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).