Skip to content

Commit 3a54cd7

Browse files
committed
Disable markdown commands when in markdown cells in notebooks
Fixes microsoft#101514
1 parent 3c77120 commit 3a54cd7

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

extensions/markdown-language-features/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"editor/title": [
7979
{
8080
"command": "markdown.showPreviewToSide",
81-
"when": "editorLangId == markdown",
81+
"when": "editorLangId == markdown && !notebookEditorFocused",
8282
"alt": "markdown.showPreview",
8383
"group": "navigation"
8484
},
@@ -120,17 +120,17 @@
120120
"commandPalette": [
121121
{
122122
"command": "markdown.showPreview",
123-
"when": "editorLangId == markdown",
123+
"when": "editorLangId == markdown && !notebookEditorFocused",
124124
"group": "navigation"
125125
},
126126
{
127127
"command": "markdown.showPreviewToSide",
128-
"when": "editorLangId == markdown",
128+
"when": "editorLangId == markdown && !notebookEditorFocused",
129129
"group": "navigation"
130130
},
131131
{
132132
"command": "markdown.showLockedPreviewToSide",
133-
"when": "editorLangId == markdown",
133+
"when": "editorLangId == markdown && !notebookEditorFocused",
134134
"group": "navigation"
135135
},
136136
{
@@ -140,7 +140,7 @@
140140
},
141141
{
142142
"command": "markdown.showPreviewSecuritySelector",
143-
"when": "editorLangId == markdown"
143+
"when": "editorLangId == markdown && !notebookEditorFocused"
144144
},
145145
{
146146
"command": "markdown.showPreviewSecuritySelector",
@@ -152,7 +152,7 @@
152152
},
153153
{
154154
"command": "markdown.preview.refresh",
155-
"when": "editorLangId == markdown"
155+
"when": "editorLangId == markdown && !notebookEditorFocused"
156156
},
157157
{
158158
"command": "markdown.preview.refresh",
@@ -165,13 +165,13 @@
165165
"command": "markdown.showPreview",
166166
"key": "shift+ctrl+v",
167167
"mac": "shift+cmd+v",
168-
"when": "editorLangId == markdown"
168+
"when": "editorLangId == markdown && !notebookEditorFocused"
169169
},
170170
{
171171
"command": "markdown.showPreviewToSide",
172172
"key": "ctrl+k v",
173173
"mac": "cmd+k v",
174-
"when": "editorLangId == markdown"
174+
"when": "editorLangId == markdown && !notebookEditorFocused"
175175
}
176176
],
177177
"configuration": {

extensions/markdown-language-features/src/features/preview.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,12 @@ export class DynamicMarkdownPreview extends Disposable implements ManagedMarkdow
612612
}));
613613

614614
this._register(vscode.window.onDidChangeActiveTextEditor(editor => {
615-
if (editor && isMarkdownFile(editor.document) && !this._locked && !this._preview.isPreviewOf(editor.document.uri)) {
615+
// Only allow previewing normal text editors which have a viewColumn: See #101514
616+
if (typeof editor?.viewColumn === 'undefined') {
617+
return;
618+
}
619+
620+
if (isMarkdownFile(editor.document) && !this._locked && !this._preview.isPreviewOf(editor.document.uri)) {
616621
const line = getVisibleLine(editor);
617622
this.update(editor.document.uri, line ? new StartingScrollLine(line) : undefined);
618623
}

0 commit comments

Comments
 (0)