From 89c5abcb0e19b737c80b44b77b8eeb04ad44593e Mon Sep 17 00:00:00 2001 From: Philipp Nieting Date: Sat, 30 Sep 2017 22:06:00 +0200 Subject: [PATCH] Improved interpreter switching Switching the interpreter is possible if no workspace is opened --- package.json | 2 +- src/client/interpreter/index.ts | 6 +++++- src/client/providers/setInterpreterProvider.ts | 3 --- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ecc33854217f..3307ab32c2ed 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ }, { "command": "python.setInterpreter", - "title": "Select Workspace Interpreter", + "title": "Select Interpreter", "category": "Python" }, { diff --git a/src/client/interpreter/index.ts b/src/client/interpreter/index.ts index 447946d7871c..d2eb6fd9e71d 100644 --- a/src/client/interpreter/index.ts +++ b/src/client/interpreter/index.ts @@ -58,7 +58,11 @@ export class InterpreterManager implements Disposable { pythonPath = path.join('${workspaceRoot}', path.relative(workspace.rootPath!, pythonPath)); } const pythonConfig = workspace.getConfiguration('python'); - pythonConfig.update('pythonPath', pythonPath).then(() => { + let global = null; + if (typeof workspace.rootPath !== 'string') { + global = true; + } + pythonConfig.update('pythonPath', pythonPath, global).then(() => { //Done }, reason => { window.showErrorMessage(`Failed to set 'pythonPath'. Error: ${reason.message}`); diff --git a/src/client/providers/setInterpreterProvider.ts b/src/client/providers/setInterpreterProvider.ts index 6021a71be60f..3eb44c640065 100644 --- a/src/client/providers/setInterpreterProvider.ts +++ b/src/client/providers/setInterpreterProvider.ts @@ -58,9 +58,6 @@ export class SetInterpreterProvider implements vscode.Disposable { } private setInterpreter() { - if (typeof vscode.workspace.rootPath !== 'string') { - return vscode.window.showErrorMessage('Please open a workspace to select the Python Interpreter'); - } this.presentQuickPick(); } } \ No newline at end of file