Skip to content

Markdown preview show cached file when switching to another tab and then switching back #271233

Closed

Description

Type: Bug

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)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.89GB (10.49GB free)
Process Argv --crash-reporter-id 70e7f6b9-91ba-40e5-b670-f0e61f59a441
Screen Reader no
VM 29%
Extensions: none
A/B Experiments
vsliv368cf:30146710
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
usemplatestapi:31297334
6518g693:31334701
aj953862:31281341
4f60g487:31327383
onetestforazureexp:31335613
6abeh943:31336334
gendocstringt:31395207
cloudbuttont:31379625
qwen_all_req:31398802
3efgi100_wstrepl:31382709
applesignin:31399435
6g47h526:31399759

Activity

  1. vs-code-engineering commented on Oct 14, 2025

    @vs-code-engineering
    Contributor

    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!

  2. YOYO-UIAT commented on Oct 14, 2025

    @YOYO-UIAT
    Author

    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.

  3. RedCMD commented on Oct 14, 2025

    @RedCMD
    Contributor

    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

    1. create markdown file
    2. open the markdown preview for the file in another group
    3. modify the markdown file
    4. hide the preview (open a new document in the same group)
    5. re-reveal the preview
    Screen.Recording.2025-10-14.180838-1.mp4
  4. added
    bug
    markdown-ext
    on Dec 9, 2025
  5. added a commit that references this issue on Apr 6, 2026
    b4099e2
  6. jgillard commented on Aug 11, 2026

    @jgillard

    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.

  7. ygoe commented on Aug 25, 2026

    @ygoe

    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.

  8. ygoe commented on Aug 28, 2026

    @ygoe

    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.

  9. ygoe commented on Aug 28, 2026

    @ygoe

    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.

  10. ygoe commented on Aug 30, 2026

    @ygoe

    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.

  11. bompus commented on Sep 5, 2026

    @bompus
    Contributor

    #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.

  12. glen-84 commented on Oct 15, 2026

    @glen-84

    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).

  13. gilney-canaltelecom commented on Oct 16, 2026

    @gilney-canaltelecom

    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 😭

  14. jzabroski commented on Oct 20, 2026

    @jzabroski

    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.

  15. glen-84 commented on Oct 25, 2026

    @glen-84

    John Zabroski (@jzabroski)

    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 already does that (when the document is up-to-date) ...

    Image

    (the bottom part is what you see when hovering over the blue marker)

  16. added
    unreleased
    on Oct 31, 2026
  17. added a commit that references this issue on Oct 31, 2026
    4e8c102
  18. added
    insiders-released
    and removed
    unreleased
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buginsiders-releasedmarkdown-extverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions