Markdown: Open Preview - doesn't work for *.prompt.md files (#270417)

This commit is contained in:
Martin Aeschlimann
2025-10-08 22:09:33 +02:00
committed by GitHub
parent 0f5bcca45d
commit cf1a93be3f
3 changed files with 19 additions and 17 deletions

View File

@@ -181,13 +181,13 @@
"command": "markdown.editor.insertLinkFromWorkspace",
"title": "%markdown.editor.insertLinkFromWorkspace%",
"category": "Markdown",
"enablement": "editorLangId == markdown && !activeEditorIsReadonly"
"enablement": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !activeEditorIsReadonly"
},
{
"command": "markdown.editor.insertImageFromWorkspace",
"title": "%markdown.editor.insertImageFromWorkspace%",
"category": "Markdown",
"enablement": "editorLangId == markdown && !activeEditorIsReadonly"
"enablement": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !activeEditorIsReadonly"
}
],
"menus": {
@@ -204,7 +204,7 @@
"editor/title": [
{
"command": "markdown.showPreviewToSide",
"when": "editorLangId == markdown && !notebookEditorFocused && !hasCustomMarkdownPreview",
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused && !hasCustomMarkdownPreview",
"alt": "markdown.showPreview",
"group": "navigation"
},
@@ -232,24 +232,24 @@
"explorer/context": [
{
"command": "markdown.showPreview",
"when": "resourceLangId == markdown && !hasCustomMarkdownPreview",
"when": "resourceLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !hasCustomMarkdownPreview",
"group": "navigation"
},
{
"command": "markdown.findAllFileReferences",
"when": "resourceLangId == markdown",
"when": "resourceLangId =~ /^(markdown|prompt|instructions|chatmode)$/",
"group": "4_search"
}
],
"editor/title/context": [
{
"command": "markdown.showPreview",
"when": "resourceLangId == markdown && !hasCustomMarkdownPreview",
"when": "resourceLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !hasCustomMarkdownPreview",
"group": "1_open"
},
{
"command": "markdown.findAllFileReferences",
"when": "resourceLangId == markdown"
"when": "resourceLangId =~ /^(markdown|prompt|instructions|chatmode)$/"
}
],
"commandPalette": [
@@ -263,17 +263,17 @@
},
{
"command": "markdown.showPreview",
"when": "editorLangId == markdown && !notebookEditorFocused",
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused",
"group": "navigation"
},
{
"command": "markdown.showPreviewToSide",
"when": "editorLangId == markdown && !notebookEditorFocused",
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused",
"group": "navigation"
},
{
"command": "markdown.showLockedPreviewToSide",
"when": "editorLangId == markdown && !notebookEditorFocused",
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused",
"group": "navigation"
},
{
@@ -283,7 +283,7 @@
},
{
"command": "markdown.showPreviewSecuritySelector",
"when": "editorLangId == markdown && !notebookEditorFocused"
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused"
},
{
"command": "markdown.showPreviewSecuritySelector",
@@ -295,7 +295,7 @@
},
{
"command": "markdown.preview.refresh",
"when": "editorLangId == markdown && !notebookEditorFocused"
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused"
},
{
"command": "markdown.preview.refresh",
@@ -303,7 +303,7 @@
},
{
"command": "markdown.findAllFileReferences",
"when": "editorLangId == markdown"
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/"
}
]
},
@@ -312,13 +312,13 @@
"command": "markdown.showPreview",
"key": "shift+ctrl+v",
"mac": "shift+cmd+v",
"when": "editorLangId == markdown && !notebookEditorFocused"
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused"
},
{
"command": "markdown.showPreviewToSide",
"key": "ctrl+k v",
"mac": "cmd+k v",
"when": "editorLangId == markdown && !notebookEditorFocused"
"when": "editorLangId =~ /^(markdown|prompt|instructions|chatmode)$/ && !notebookEditorFocused"
}
],
"configuration": {

View File

@@ -21,6 +21,7 @@ import { ExtensionContentSecurityPolicyArbiter } from './preview/security';
import { loadDefaultTelemetryReporter } from './telemetryReporter';
import { MdLinkOpener } from './util/openDocumentLink';
import { registerUpdatePastedLinks } from './languageFeatures/updateLinksOnPaste';
import { markdownLanguageIds } from './util/file';
export function activateShared(
context: vscode.ExtensionContext,
@@ -54,7 +55,7 @@ function registerMarkdownLanguageFeatures(
commandManager: CommandManager,
parser: IMdParser,
): vscode.Disposable {
const selector: vscode.DocumentSelector = { language: 'markdown', scheme: '*' };
const selector: vscode.DocumentSelector = markdownLanguageIds;
return vscode.Disposable.from(
// Language features
registerDiagnosticSupport(selector, commandManager),

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode';
import { CommandManager } from '../commandManager';
import { isMarkdownFile } from '../util/file';
// Copied from markdown language service
@@ -88,7 +89,7 @@ function registerMarkdownStatusItem(selector: vscode.DocumentSelector, commandMa
const update = () => {
const activeDoc = vscode.window.activeTextEditor?.document;
const markdownDoc = activeDoc?.languageId === 'markdown' ? activeDoc : undefined;
const markdownDoc = activeDoc && isMarkdownFile(activeDoc) ? activeDoc : undefined;
const enabled = vscode.workspace.getConfiguration('markdown', markdownDoc).get(enabledSettingId);
if (enabled) {