Skip to content

Commit

Permalink
enable turning off the variable provider
Browse files Browse the repository at this point in the history
  • Loading branch information
amunger committed Oct 3, 2024
1 parent d072503 commit 3559536
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@
"experimental"
]
},
"python.REPL.provideVariables": {
"default": true,
"description": "%python.REPL.provideVariables.description%",
"scope": "resource",
"type": "boolean"
},
"python.testing.autoTestDiscoverOnSaveEnabled": {
"default": true,
"description": "%python.testing.autoTestDiscoverOnSaveEnabled.description%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"python.pixiToolPath.description": "Path to the pixi executable.",
"python.EnableREPLSmartSend.description": "Toggle Smart Send for the Python REPL. Smart Send enables sending the smallest runnable block of code to the REPL on Shift+Enter and moves the cursor accordingly.",
"python.REPL.sendToNativeREPL.description": "Toggle to send code to Python REPL instead of the terminal on execution. Turning this on will change the behavior for both Smart Send and Run Selection/Line in the Context Menu.",
"python.REPL.provideVariables.description": "Toggle to provide variables for the REPL variable view for the native REPL.",
"python.tensorBoard.logDirectory.description": "Set this setting to your preferred TensorBoard log directory to skip log directory prompt when starting TensorBoard.",
"python.tensorBoard.logDirectory.markdownDeprecationMessage": "Tensorboard support has been moved to the extension [Tensorboard extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.tensorboard). Instead use the setting `tensorBoard.logDirectory`.",
"python.tensorBoard.logDirectory.deprecationMessage": "Tensorboard support has been moved to the extension Tensorboard extension. Instead use the setting `tensorBoard.logDirectory`.",
Expand Down
12 changes: 10 additions & 2 deletions src/client/repl/variables/variablesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import {
EventEmitter,
Event,
NotebookVariableProvider,
Uri,
} from 'vscode';
import { VariableResultCache } from './variableResultCache';
import { IVariableDescription } from './types';
import { VariableRequester } from './variableRequester';
import { getConfiguration } from '../../common/vscodeApis/workspaceApis';

export class VariablesProvider implements NotebookVariableProvider {
private readonly variableResultCache = new VariableResultCache();
Expand All @@ -36,7 +38,9 @@ export class VariablesProvider implements NotebookVariableProvider {
const notebook = this.getNotebookDocument();
if (notebook) {
this.executionCount += 1;
this._onDidChangeVariables.fire(notebook);
if (isEnabled()) {
this._onDidChangeVariables.fire(notebook);
}
}
}

Expand All @@ -48,7 +52,7 @@ export class VariablesProvider implements NotebookVariableProvider {
token: CancellationToken,
): AsyncIterable<VariablesResult> {
const notebookDocument = this.getNotebookDocument();
if (token.isCancellationRequested || !notebookDocument || notebookDocument !== notebook) {
if (!isEnabled() || token.isCancellationRequested || !notebookDocument || notebookDocument !== notebook) {
return;
}

Expand Down Expand Up @@ -144,3 +148,7 @@ function getVariableResultCacheKey(uri: string, parent: Variable | undefined, st
}
return `${uri}:${parentKey}`;
}

function isEnabled(resource?: Uri) {
return getConfiguration('python', resource).get('REPL.provideVariables');
}

0 comments on commit 3559536

Please sign in to comment.