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;