Skip to content

Make it easy to switch current md doc between preview and edit mode#313428

Merged
mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz:dev/mjbvz/robust-bovid
Apr 30, 2026
Merged

Make it easy to switch current md doc between preview and edit mode#313428
mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz:dev/mjbvz/robust-bovid

Conversation

@mjbvz
Copy link
Copy Markdown
Collaborator

@mjbvz mjbvz commented Apr 30, 2026

Fixes #312425
Fixes #301686

Also adds a toggle preview command

Copilot AI review requested due to automatic review settings April 30, 2026 04:19
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

This PR adds commands and UI contributions to quickly switch a Markdown document between the standard text editor and the Markdown preview custom editor, including a new toggle command and associated keybinding.

Changes:

  • Set the custom editor preview tab icon for vscode.markdown.preview.editor.
  • Add markdown.reopenAsPreview, markdown.reopenAsSource, and markdown.togglePreview commands and register them.
  • Contribute new commands, editor title actions, and remap Shift+Ctrl/Cmd+V to the new toggle.
Show a summary per file
File Description
extensions/markdown-language-features/src/preview/preview.ts Sets the webview icon for the Markdown preview custom editor.
extensions/markdown-language-features/src/commands/reopenAsPreview.ts Adds commands to reopen as preview/source and a toggle command.
extensions/markdown-language-features/src/commands/index.ts Registers the newly added commands.
extensions/markdown-language-features/package.nls.json Adds localized titles for the new commands.
extensions/markdown-language-features/package.json Adds command/menu contributions and updates the default preview keybinding to toggle.

Copilot's findings

Comments suppressed due to low confidence (1)

extensions/markdown-language-features/package.json:372

  • The shift+ctrl/cmd+v keybinding was changed to use resourceLangId. In keybinding contexts, resourceLangId can be set from non-editor focus (e.g. Explorer selection), which can make this shortcut active outside the editor and run markdown.togglePreview against whatever editor is currently active. To keep the shortcut scoped to the active markdown editor/preview, consider using editorLangId =~ ... for the text editor case and activeCustomEditorId == 'vscode.markdown.preview.editor' (and/or activeWebviewPanelId == 'markdown.preview') for preview cases instead of resourceLangId.
        "command": "markdown.togglePreview",
        "key": "shift+ctrl+v",
        "mac": "shift+cmd+v",
        "when": "resourceLangId =~ /^(markdown|prompt|instructions|chatagent|skill)$/ && !notebookEditorFocused"
      }
  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread extensions/markdown-language-features/package.json
@mjbvz mjbvz enabled auto-merge April 30, 2026 04:59
@mjbvz mjbvz self-assigned this Apr 30, 2026
@mjbvz mjbvz merged commit cc71115 into microsoft:main Apr 30, 2026
30 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone Apr 30, 2026
@paige-clark
Copy link
Copy Markdown

Awesome!! Thank you Matt!

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.

markdown preview Markdown Preview: Button to toggle between reading and writing in the same tab

4 participants