You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Markdown preview show cached file when switching to another tab and then switching back #271233
bugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code Insidersmarkdown-extThe Markdown extension: language features and previewverifiedVerification succeeded
Create a markdown file, then open preview, and open some image files beside the preview tab. Switch to pdf, and then switch back, the markdown preview shows some older version of the markdown file.
VS Code version: Code 1.100.2 (848b80a, 2025-05-14T21:47:40.416Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
Item
Value
CPUs
Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2592)
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.105.0. Please try upgrading to the latest version and checking whether this issue remains.
Yingzhi Zhao (@YOYO-UIAT) png and pdf has nothing to do with this
you didn't state when you needed to edit the markdown file
a screenshot or screencast would have been very helpful
I've also bumped into this issue when using agents that edit md files and I cannot get the preview to show the updated version, but this is happening even if I close and re-open the preview. It's like there's a stale cache somewhere. If this is different enough I can open a new issue.
I also noticed this more often recently after Claude Code has edited a markdown file while I had its preview open. This is the fullsize preview, not the old side-by-side next to the source. No markdown extensions installed, just plain VSCode. It's not reproducible, sometimes the preview updates as expected, even while displayed and active, and sometimes an older version of it returns sometime later. I think I always refreshed it so far by switching to source view and then back to preview, but I'm not certain. It happens too rarely for me to recognise a pattern, but its effect is severe confusion. Severe enough to treat with priority. I need to be able to rely on my editing tools. If I can't trust what I see, the whole thing isn't worth anything.
The strange thing is also that the preview is up-to-date once, then I open another document, close it, and the same preview window now shows an older version of the file.
That preview doesn't seem to behave well anyway. It seems to be recreated every time the document tab is activated: selected text is deselected, search results and the searchbox disappear. It appears to redo the whole preview from scratch every time the document is switched to, discarding everything except the scroll position. Yet it somehow manages to produce stale content!
Something must be severely wrong in there. It meets neither performance nor correctness expectations. Usually you trade one for the other, but here you trade both for nothing.
Stupid thing. The markdown preview does what it wants and is not usable anymore at all. It causes repeated confusion about what I see and what is actually there. I'm revising a list of numbered items and then tell Claude the wrong numbers because VSCode showed me some bogus content and not the real file! Need to look for a different solution now, all trust is lost.
More bugs need fixing with markdown: I opened a .md file, switched to preview, scrolled a bit down, switched back to source view, scrolled to the top and put the cursor at the top. Now every time I go back to this document tab, the view scrolls down to where the preview was. But this is not the preview, it's the source and it should remember its scroll position like any other tab. The preview now gets in my way even when I'm not using it. Definitely an increase in severity.
#334681 addresses the sequence in the original report: modify the file while the preview is visible, hide the preview behind another editor, show it again.
What happens: while the panel is visible, the preview applies changes by posting an updateContent message to the webview and leaves webview.html as it was after the last full render. The preview does not use retainContextWhenHidden, so hiding the panel discards the webview and revealing it rebuilds it from that stale webview.html. The PR reloads the html when a panel that received an in-place update is hidden, for both the dynamic preview and the vscode.markdown.preview.editor custom editor.
The later comment about closing and reopening the preview is a different path (the webview is created fresh there), tracked by #332081 and #333712.
On the other PRs linked here: #308427 calls the non-forced refresh(), which returns at the version check because the document version did not change since the in-place update; with its diff applied on top of 1.128.0 the re-shown preview still displays the old content. #166932 does fix the dynamic preview, at the cost of reloading the page every time the preview loses focus, and it leaves the custom editor unfixed.
Same mechanism as the closed #165188 and #244328, and as the tab-switch reports in #265277.
Henning Dieterichs (@hediet) This issue is still assigned to Matt Bierner, who has since moved on from VS Code. You're assigned to #331900, #332081, and #333712, and have done most of the recent work in extensions/markdown-language-features. Could you take this one over, or pass it to whoever owns the Markdown preview now?
AI agents have made this bug much more visible. An agent such as Copilot or Claude Code edits a Markdown file while its preview is open. The preview then keeps showing an older version, or goes back to one after a tab switch. Nothing shows that the content is stale, so people review and act on text that is no longer in the file. Several comments above describe exactly this.
There are already several open PRs for this bug and for #331900, where a preview of a file that has no text editor open stops refreshing at all:
Yes, PLEASE, can someone fix the problem of the preview showing outdated content AND losing scroll position? Both are driving me nuts for the past couple of weeks 😭
Glen (@glen-84) Refreshing the document gets us to basic sanity state, but I opened #343080 because I think the ideal workflow is to have "Markdown Preview" mode actually show the red-delete/green-addition changes without having to flip modes. It gets especially fatiguing when Copilot loses the plot of what is asked and writes a bunch of jibberish. Markdown has personally become an unfortunate critical part of my Copilot workflow - and I have nothing better to replace it with. I have confluence.cs and jira.cs .net file-based apps that synch all my atlassian content back and forth across markdown files in order to ensure I am always working on the latest engineering specs, etc.
bugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code Insidersmarkdown-extThe Markdown extension: language features and previewverifiedVerification succeeded
Activity
vs-code-engineering commentedon Oct 14, 2025
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.105.0. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!
YOYO-UIAT commentedon Oct 14, 2025
ok I've upgraded my vscode, but it does not help :(
Actually I reported this issue half a year ago: #244328, but somehow it was closed without being fixed.
RedCMD commentedon Oct 14, 2025
can confirm
Yingzhi Zhao (@YOYO-UIAT) png and pdf has nothing to do with this
you didn't state when you needed to edit the markdown file
a screenshot or screencast would have been very helpful
Matt Bierner (@mjbvz) why did you instantly close the previous issue?
reproduce
Screen.Recording.2025-10-14.180838-1.mp4
fix(markdown): refresh preview when panel becomes visible again
jgillard commentedon Aug 11, 2026
I've also bumped into this issue when using agents that edit md files and I cannot get the preview to show the updated version, but this is happening even if I close and re-open the preview. It's like there's a stale cache somewhere. If this is different enough I can open a new issue.
ygoe commentedon Aug 25, 2026
I also noticed this more often recently after Claude Code has edited a markdown file while I had its preview open. This is the fullsize preview, not the old side-by-side next to the source. No markdown extensions installed, just plain VSCode. It's not reproducible, sometimes the preview updates as expected, even while displayed and active, and sometimes an older version of it returns sometime later. I think I always refreshed it so far by switching to source view and then back to preview, but I'm not certain. It happens too rarely for me to recognise a pattern, but its effect is severe confusion. Severe enough to treat with priority. I need to be able to rely on my editing tools. If I can't trust what I see, the whole thing isn't worth anything.
ygoe commentedon Aug 28, 2026
The strange thing is also that the preview is up-to-date once, then I open another document, close it, and the same preview window now shows an older version of the file.
That preview doesn't seem to behave well anyway. It seems to be recreated every time the document tab is activated: selected text is deselected, search results and the searchbox disappear. It appears to redo the whole preview from scratch every time the document is switched to, discarding everything except the scroll position. Yet it somehow manages to produce stale content!
Something must be severely wrong in there. It meets neither performance nor correctness expectations. Usually you trade one for the other, but here you trade both for nothing.
ygoe commentedon Aug 28, 2026
Stupid thing. The markdown preview does what it wants and is not usable anymore at all. It causes repeated confusion about what I see and what is actually there. I'm revising a list of numbered items and then tell Claude the wrong numbers because VSCode showed me some bogus content and not the real file! Need to look for a different solution now, all trust is lost.
ygoe commentedon Aug 30, 2026
More bugs need fixing with markdown: I opened a .md file, switched to preview, scrolled a bit down, switched back to source view, scrolled to the top and put the cursor at the top. Now every time I go back to this document tab, the view scrolls down to where the preview was. But this is not the preview, it's the source and it should remember its scroll position like any other tab. The preview now gets in my way even when I'm not using it. Definitely an increase in severity.
bompus commentedon Sep 5, 2026
#334681 addresses the sequence in the original report: modify the file while the preview is visible, hide the preview behind another editor, show it again.
What happens: while the panel is visible, the preview applies changes by posting an
updateContentmessage to the webview and leaveswebview.htmlas it was after the last full render. The preview does not useretainContextWhenHidden, so hiding the panel discards the webview and revealing it rebuilds it from that stalewebview.html. The PR reloads the html when a panel that received an in-place update is hidden, for both the dynamic preview and thevscode.markdown.preview.editorcustom editor.The later comment about closing and reopening the preview is a different path (the webview is created fresh there), tracked by #332081 and #333712.
On the other PRs linked here: #308427 calls the non-forced
refresh(), which returns at the version check because the document version did not change since the in-place update; with its diff applied on top of 1.128.0 the re-shown preview still displays the old content. #166932 does fix the dynamic preview, at the cost of reloading the page every time the preview loses focus, and it leaves the custom editor unfixed.Same mechanism as the closed #165188 and #244328, and as the tab-switch reports in #265277.
glen-84 commentedon Oct 15, 2026
Henning Dieterichs (@hediet) This issue is still assigned to Matt Bierner, who has since moved on from VS Code. You're assigned to #331900, #332081, and #333712, and have done most of the recent work in
extensions/markdown-language-features. Could you take this one over, or pass it to whoever owns the Markdown preview now?AI agents have made this bug much more visible. An agent such as Copilot or Claude Code edits a Markdown file while its preview is open. The preview then keeps showing an older version, or goes back to one after a tab switch. Nothing shows that the content is stale, so people review and act on text that is no longer in the file. Several comments above describe exactly this.
There are already several open PRs for this bug and for #331900, where a preview of a file that has no text editor open stops refreshing at all:
Could this be prioritized, and could these PRs get a review?
Drafted by Claude (Anthropic AI assistant).
gilney-canaltelecom commentedon Oct 16, 2026
Yes, PLEASE, can someone fix the problem of the preview showing outdated content AND losing scroll position? Both are driving me nuts for the past couple of weeks 😭
jzabroski commentedon Oct 20, 2026
Glen (@glen-84) Refreshing the document gets us to basic sanity state, but I opened #343080 because I think the ideal workflow is to have "Markdown Preview" mode actually show the red-delete/green-addition changes without having to flip modes. It gets especially fatiguing when Copilot loses the plot of what is asked and writes a bunch of jibberish. Markdown has personally become an unfortunate critical part of my Copilot workflow - and I have nothing better to replace it with. I have confluence.cs and jira.cs .net file-based apps that synch all my atlassian content back and forth across markdown files in order to ensure I am always working on the latest engineering specs, etc.
glen-84 commentedon Oct 25, 2026
John Zabroski (@jzabroski)
It already does that (when the document is up-to-date) ...
(the bottom part is what you see when hovering over the blue marker)
Refresh markdown preview html before a hidden panel is rebuilt (micro…