Repository navigation
Done
Description
Type: Bug
- Open a markdown file in preview mode and scroll to a position
- Switch to the text editor mode for the markdown file
- Now scroll to a different position
- Switch tabs away from the markdown file and then back to the markdown file
- Expected behaviour: editor does not scroll when switching back
- Actual behaviour: editor always scrolls back to the position it was in the preview
VS Code version: Code 1.120.0 (0958016, 2026-05-12T20:17:22Z)
OS version: Windows_NT x64 10.0.26200
Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 13th Gen Intel(R) Core(TM) i5-1345U (12 x 2496) |
| GPU Status | 2d_canvas: enabled GPU0: VENDOR= 0x8086, DEVICE=0xa7a1 [Intel(R) Iris(R) Xe Graphics], DRIVER_VENDOR=Intel, DRIVER_VERSION=32.0.101.7084 ACTIVE GPU1: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.8246 Machine model name: Machine model version: direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off trees_in_viz: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | undefined |
| Memory (System) | 15.66GB (2.29GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
Extensions (35)
| Extension | Author (truncated) | Version |
|---|---|---|
| copilot-chat | Git | 0.48.1 |
| ruff | cha | 2026.42.0 |
| vscode-cylc | cyl | 1.3.0 |
| shebang-language-associator | dav | 1.4.0 |
| vscode-eslint | dba | 3.0.24 |
| gitlens | eam | 17.12.2 |
| vscode-github-actions | git | 0.31.5 |
| vscode-pull-request-github | Git | 0.144.0 |
| git-graph | mhu | 1.30.0 |
| black-formatter | ms- | 2026.4.0 |
| debugpy | ms- | 2026.6.0 |
| flake8 | ms- | 2026.6.0 |
| isort | ms- | 2026.5.11331015 |
| mypy-type-checker | ms- | 2026.4.0 |
| python | ms- | 2026.4.0 |
| vscode-pylance | ms- | 2026.2.1 |
| jupyter | ms- | 2025.9.1 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.3.0 |
| vscode-jupyter-cell-tags | ms- | 0.1.9 |
| vscode-jupyter-slideshow | ms- | 0.1.6 |
| remote-ssh | ms- | 0.122.0 |
| remote-wsl | ms- | 0.104.3 |
| powershell | ms- | 2025.4.0 |
| remote-explorer | ms- | 0.5.0 |
| remote-server | ms- | 1.5.3 |
| sqlite-viewer | qwt | 25.12.2 |
| vscode-yaml | red | 1.23.0 |
| jinjahtml | sam | 0.20.0 |
| even-better-toml | tam | 0.21.2 |
| shellcheck | tim | 0.39.5 |
| simple-rst | tro | 1.5.4 |
| explorer | vit | 1.50.4 |
| volar | Vue | 3.3.0 |
| vscode-markdown-alert | yah | 0.0.4 |
(1 theme extensions excluded)
demo720p.mp4
Reacted by A. Regnander, Fakie, danieltodor, stevenlele, Richard Roberts, mapben, Albert Clèrigues, Khoi, rdong8, Artem Orlov and 30 more
Activity
danieltodor commentedon Jun 21, 2026
Same (or similar) issue haunts me for months now.
When i scroll somewhere in a markdown file and switch between the preview and edit mode with ctrl+shift+v the scroll position keeps jumping to the top of the file which is very annoying when i just wanted to check if my edit renders correctly. And sometimes when i scroll back to that position after the preview and switch between the editor/preview state again, then the scroll position keeps jumping to that frequent position instead of the top. But it's still not the scroll position where it should be (because i scrolled somewhere else before that).
richardroberts-slamcore commentedon Jul 16, 2026
Yes, I have the same issue. The scroll position in the markdown editor jumps when the focus has been in another editor pane or another tab and then the focus is returned to the markdown editor. Note that the cursor does not jump, only the scroll position. The cursor is often scrolled out of the view in fact (and moving the cursor using one of the arrow keys then of course returns the scrolling position such that the cursor is again visible). This bug occurs whether or not the markdown preview of that file is also open.
gomico commentedon Jul 17, 2026
Same, still exists in 1.129.0
pasting my issue content here since it's closed as duplicated:
markdown.togglePreviewopens the preview in a new tab (side-by-side).markdown.togglePreviewnow defaults to opening in the current tab, but the scroll position issue does not occur here. However, the preview always opens scrolled to the top, regardless of where the source editor was scrolled to.Agent analysis suggests that:
RichardGTsl commentedon Jul 17, 2026
I have the same problem. It affects some files and not others. The affected files have headings down to level 4 (####). The unaffected files only go to level 2. (##) Perhaps this has something to do with the bug.
lmBored commentedon Jul 26, 2026
I'm having the same issue in VSCode Insiders 1.128.0 and 1.131.0. It fixes itself after reloading windows, but it's a big inconvenience
edit: Please prioritize these issues over AI support. These bugs should be prioritized for a code editor.
RichardGTsl commentedon Jul 31, 2026
I've think I had one instance where closing the file and re-opening it resolved the issue. I've definitely had another example where re-opening files made no difference. Restarting vscode fixed it though.
RichardGTsl commentedon Jul 31, 2026
I've just confirmed that re-opening files doesn't help but restarting VSCode fixes the problem.
beifangzhishi-ops commentedon Aug 6, 2026
Same issue here on Windows.
I can also confirm that disabling both
markdown.preview.scrollEditorWithPreviewand
markdown.preview.scrollPreviewWithEditordoes not help — the editorstill jumps back to the locked position after switching tabs/editor groups.
A restart (or reloading the window) does fix it temporarily, but the bug
comes back reliably after this sequence:
The editor then jumps back to the position that was at the top of the
preview when it was closed. So the scroll position gets "re-locked" every
time the preview is opened and closed.
One more observation that might narrow it down:
The bug only reproduces when there is at least one other file tab open in the
window — either in the same editor group or in a floating editor window.
With only the affected Markdown file open (with or without its preview), the
jump does not happen when switching back.
CarterRoll commentedon Aug 24, 2026
I noticed that the preview stays where you last reloaded the preview. If you click the three dots in the top right and click "Refresh Preview", that "saves" a new scroll location when you click back into the tab.
joseph423 commentedon Aug 28, 2026
Are we gonna have a solution to this?
lmBored commentedon Aug 28, 2026
Are you asking VSCode dev to pause their AI development and actually improve the editor? No way. Check back in a year /s
lmBored commentedon Sep 13, 2026
Matt Bierner (@mjbvz) is this issue planned ahead to be worked on in near future? I see some vscode's fork already fixed it so it shouldn't be hard to just copy their implementation
1 remaining item
evermake commentedon Sep 16, 2026
+1, issue persists even after deleting and re-creating the file. Very frustrating...
phyloong commentedon Sep 17, 2026
Version 1.138, this problem still exists.
fastcat commentedon Sep 18, 2026
Maybe related to #329625?
vworld commentedon Sep 21, 2026
The issue persists, and the disorientation it causes is frustrating enough that switching to another IDE for Markdown editing seems to be an easier choice.
A fix would be greatly appreciated. An editor unexpectedly jumping to a different scroll position when switching tabs is disruptive to the editing workflow and isn't something that can reasonably be worked around.
dmoc24 commentedon Sep 29, 2026
Given how much AI driven development relies on markdown files I'm surprised this issue is not top priority. It's super disorienting to have to find the correct position in a plan.md file time and again.
astroflexx commentedon Oct 8, 2026
Same issue. Please fix.
AmitTzah commentedon Oct 22, 2026
Same issue. Extremely annoying...
TheLostTemple2023 commentedon Oct 23, 2026
Version 1.143.1, this problem still exists.
njoAI commentedon Oct 23, 2026
Workaround: Run "Developer: Reload Window". Seems to clear it for me for a while.
I am also very surprised, that this is not taken care of in the age of AI. Currently I see such documents half of my work day...
ermse commentedon Oct 26, 2026
Context first, because this issue and #147718 are two halves of one design problem.
The markdown preview and the markdown text editor share a single remembered line number per resource, and it is used as a bidirectional sync anchor without any record of which side scrolled last. Whichever side you did not touch most recently can therefore overwrite the position of the side you did:
Both are the same root design point seen from opposite ends, but they fail through different code, so the rest of this comment is specific to the editor side.
Still present in 1.143.1 (e646868, Windows x64), and the cause here looks precise and fairly small.
MarkdownPreviewManagerre-applies a remembered preview scroll line to the text editor every time a markdown editor becomes active:That line comes from
setPreviousStaticEditorLine, whichStaticMarkdownPreviewfires on every preview scroll. The handoff is clearly meant to be one-shot, and in the opposite direction it is:getPreviousStaticEditorLineByUrinever deletes the entry, so the preview's last scroll line is retained in#previousStaticEditorInfofor the lifetime of the extension host and re-applied on every subsequent activation of that editor. That matches the reported behaviour exactly — not a one-time jump after toggling the preview, but the editor snapping back to the same preview position again and again, overwriting the position from step 3 each time you return to the tab.It also explains Nils Johnsen (@njoAI)'s workaround above:
Developer: Reload WindowrecreatesTopmostLineMonitorwith an emptyResourceMap, so the stale entry is gone "for a while" — until the preview is opened and scrolled again.The fix looks like it should mirror the text-editor side: delete the entry on read, and/or skip the scroll when the editor already has its own newer view state, rather than treating the stored preview line as a permanent anchor for the document.
Dukejung commentedon Oct 28, 2026
Confirming the analysis above. On 1.143.1 (e646868, WSL remote), I applied the one-line change to the built-in extension's
dist/extension.js, makinggetPreviousStaticEditorLineByUriconsume the entry the same waygetPreviousTextEditorLineByUridoes:After a window reload, the editor no longer snaps back to the preview's position when I return to the tab. Switching from the preview back to the editor with Ctrl+Shift+V still lands on the preview's position once, so the intended handoff is kept.
markdown: stop snapping the editor back to the preview scroll position (