From 7e5d09bf3f5889d4e388c338e6016407a0caf32e Mon Sep 17 00:00:00 2001 From: Matt Bierner <12821956+mjbvz@users.noreply.github.com> Date: Thu, 30 Apr 2026 12:38:57 -0700 Subject: [PATCH] Enable toggle md preview in modals/agents --- extensions/markdown-language-features/package.json | 10 ++++++++++ .../browser/parts/editor/editorCommandsContext.ts | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/extensions/markdown-language-features/package.json b/extensions/markdown-language-features/package.json index d8a5ebd9b4c..a9de8b96041 100644 --- a/extensions/markdown-language-features/package.json +++ b/extensions/markdown-language-features/package.json @@ -263,6 +263,16 @@ "when": "editorLangId =~ /^(markdown|prompt|instructions|chatagent|skill)$/ && !notebookEditorFocused && !hasCustomMarkdownPreview", "alt": "markdown.showPreview", "group": "navigation" + }, + { + "command": "markdown.reopenAsPreview", + "when": "activeEditor == workbench.editors.files.textFileEditor && resourceLangId =~ /^(markdown|prompt|instructions|chatagent|skill)$/ && !notebookEditorFocused && !hasCustomMarkdownPreview", + "group": "navigation" + }, + { + "command": "markdown.reopenAsSource", + "when": "activeCustomEditorId == 'vscode.markdown.preview.editor'", + "group": "navigation" } ], "explorer/context": [ diff --git a/src/vs/workbench/browser/parts/editor/editorCommandsContext.ts b/src/vs/workbench/browser/parts/editor/editorCommandsContext.ts index 7eacf6e8dfc..eb4cd20a6c5 100644 --- a/src/vs/workbench/browser/parts/editor/editorCommandsContext.ts +++ b/src/vs/workbench/browser/parts/editor/editorCommandsContext.ts @@ -66,9 +66,10 @@ function getCommandsContext(commandArgs: unknown[], editorService: IEditorServic // Get editor context for which the command was triggered let editorContext = getEditorContextFromCommandArgs(commandArgs, isListAction, editorService, editorGroupsService, listService); - // If the editor context can not be determind use the active editor + // If the editor context can not be determined use the active editor if (!editorContext) { - const activeGroup = editorGroupsService.activeGroup; + const modalEditorPart = editorGroupsService.activeModalEditorPart; + const activeGroup = modalEditorPart?.activeGroup ?? editorGroupsService.activeGroup; const activeEditor = activeGroup.activeEditor; editorContext = { groupId: activeGroup.id, editorIndex: activeEditor ? activeGroup.getIndexOfEditor(activeEditor) : undefined }; isListAction = false;