Skip to content

Fix markdown cell not re-rendering when re-executed (#151151)#319247

Open
Tatlatat wants to merge 1 commit into
microsoft:mainfrom
Tatlatat:fix/151151-markdown-image-rerender
Open

Fix markdown cell not re-rendering when re-executed (#151151)#319247
Tatlatat wants to merge 1 commit into
microsoft:mainfrom
Tatlatat:fix/151151-markdown-image-rerender

Conversation

@Tatlatat
Copy link
Copy Markdown

@Tatlatat Tatlatat commented Jun 1, 2026

A markdown cell with an <img> pointing to a missing file shows a broken image. After the file is created and the cell is re-executed/re-rendered without editing its text, the image stayed broken because the preview was not re-rendered when its content was unchanged.

Thread a forceRerender flag from the view layer down to the webview: MarkupCell now forces a re-render whenever the cell leaves edit mode (editStateChanged) — covering Enter, the toolbar, and Escape — so that showMarkupPreview bypasses its unchanged-content short-circuit and the webview re-fetches resources such as <img> tags. Content/metadata-only, layout, scroll and selection changes are unaffected.

A markdown cell with an `<img>` pointing to a missing file shows a broken
image. After the file is created and the cell is re-executed/re-rendered
without editing its text, the image stayed broken because the preview was
not re-rendered when its content was unchanged.

Thread a `forceRerender` flag from the view layer down to the webview:
`MarkupCell` now forces a re-render whenever the cell leaves edit mode
(`editStateChanged`) — covering Enter, the toolbar, and Escape — so that
`showMarkupPreview` bypasses its unchanged-content short-circuit and the
webview re-fetches resources such as `<img>` tags. Content/metadata-only,
layout, scroll and selection changes are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 1, 2026 02:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds a “force re-render” path for markup previews so the preview is refreshed even when the markdown source/metadata is unchanged (e.g., to re-fetch resources like images after leaving edit mode).

Changes:

  • Extend markup preview rendering APIs to accept a forceRerender boolean.
  • Trigger forced preview refresh when a markup cell’s edit state changes.
  • Update webview-side diffing logic to bypass “same content/metadata” short-circuit when forced.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts Adds forceRerender parameter and bypasses same-content checks to re-send render messages.
src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.ts Propagates an edit-state-derived forceRerender flag into preview updates.
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts Documents and threads forceRerender through createMarkupPreview to the webview layer.
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts Updates the editor delegate interface to accept optional forceRerender.

Comment on lines +135 to +138
// When the cell leaves edit mode (e.g. it was rendered/executed via Enter, the
// toolbar, or Escape) force the preview to re-render even if the markdown source is
// unchanged, so that resources such as <img> tags are re-fetched. See #151151.
this.viewUpdate(e.editStateChanged);
readonly onDidChangeOptions: Event<void>;
readonly onDidChangeDecorations: Event<void>;
createMarkupPreview(cell: ICellViewModel): Promise<void>;
createMarkupPreview(cell: ICellViewModel, forceRerender?: boolean): Promise<void>;
@Tatlatat
Copy link
Copy Markdown
Author

Tatlatat commented Jun 1, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants