diff --git a/CHANGELOG.md b/CHANGELOG.md index f6414c67687..2ec36f93636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,8 @@ ([#4664](https://github.com/Microsoft/vscode-jupyter/issues/4664)) 1. Add notebook codicon for Juypter viewContainer. ([#4538](https://github.com/Microsoft/vscode-jupyter/issues/4538)) +1. Allow options to show native variable view only when looking at native notebooks. + ([#4761](https://github.com/Microsoft/vscode-jupyter/issues/4761)) ### Code Health diff --git a/package.json b/package.json index 168f05dc617..518b9983387 100644 --- a/package.json +++ b/package.json @@ -728,7 +728,7 @@ "dark": "resources/dark/variable_explorer.svg" }, "category": "Jupyter", - "enablement": "!jupyter.variableViewVisible" + "enablement": "notebookViewType == jupyter-notebook && !jupyter.variableViewVisible" } ], "menus": { @@ -1294,7 +1294,7 @@ "command": "jupyter.openVariableView", "title": "%jupyter.command.jupyter.openVariableView.title%", "category": "Jupyter", - "when": "jupyter.isnativeactive" + "when": "notebookViewType == jupyter-notebook" }, { "command": "jupyter.selectNativeJupyterUriFromToolBar", @@ -1839,7 +1839,7 @@ "type": "webview", "id": "jupyterViewVariables", "name": "Variables", - "when": "jupyter.isnativeactive" + "when": "jupyter.isvscodenotebookactive" } ] } diff --git a/src/client/datascience/commands/activeEditorContext.ts b/src/client/datascience/commands/activeEditorContext.ts index 4a43dc0afee..47147de5651 100644 --- a/src/client/datascience/commands/activeEditorContext.ts +++ b/src/client/datascience/commands/activeEditorContext.ts @@ -40,6 +40,7 @@ export class ActiveEditorContextService implements IExtensionSingleActivationSer private isNotebookTrusted: ContextKey; private isPythonFileActive: boolean = false; private isPythonNotebook: ContextKey; + private isVSCodeNotebookActive: ContextKey; constructor( @inject(IInteractiveWindowProvider) private readonly interactiveProvider: IInteractiveWindowProvider, @inject(INotebookEditorProvider) private readonly notebookEditorProvider: INotebookEditorProvider, @@ -82,6 +83,7 @@ export class ActiveEditorContextService implements IExtensionSingleActivationSer this.hasNativeNotebookCells = new ContextKey(EditorContexts.HaveNativeCells, this.commandManager); this.isNotebookTrusted = new ContextKey(EditorContexts.IsNotebookTrusted, this.commandManager); this.isPythonNotebook = new ContextKey(EditorContexts.IsPythonNotebook, this.commandManager); + this.isVSCodeNotebookActive = new ContextKey(EditorContexts.IsVSCodeNotebookActive, this.commandManager); } public dispose() { this.disposables.forEach((item) => item.dispose()); @@ -122,6 +124,14 @@ export class ActiveEditorContextService implements IExtensionSingleActivationSer } private onDidChangeActiveNotebookEditor(e?: INotebookEditor) { this.nativeContext.set(!!e).ignoreErrors(); + + // jupyter.isnativeactive is set above, but also set jupyter.isvscodenotebookactive + // if the active document is also a vscode document + if (e && e.type === 'native') { + this.isVSCodeNotebookActive.set(true).ignoreErrors(); + } else { + this.isVSCodeNotebookActive.set(false).ignoreErrors(); + } this.isNotebookTrusted.set(e?.model?.isTrusted === true).ignoreErrors(); this.isPythonNotebook.set(isPythonNotebook(e?.model?.metadata)).ignoreErrors(); this.updateMergedContexts(); diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 50e84d98809..391f688f162 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -166,6 +166,7 @@ export namespace EditorContexts { export const CanRestartNotebookKernel = 'jupyter.notebookeditor.canrestartNotebookkernel'; export const CanInterruptNotebookKernel = 'jupyter.notebookeditor.canInterruptNotebookKernel'; export const IsPythonNotebook = 'jupyter.ispythonnotebook'; + export const IsVSCodeNotebookActive = 'jupyter.isvscodenotebookactive'; } export namespace RegExpValues {