Skip to content

Commit 9c7a8e3

Browse files
KavakuoDonJayamanne
authored andcommitted
Improved interpreter switching (DonJayamanne#1263)
Switching the interpreter is possible if no workspace is opened
1 parent 24c2b66 commit 9c7a8e3

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
},
118118
{
119119
"command": "python.setInterpreter",
120-
"title": "Select Workspace Interpreter",
120+
"title": "Select Interpreter",
121121
"category": "Python"
122122
},
123123
{

src/client/interpreter/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ export class InterpreterManager implements Disposable {
5858
pythonPath = path.join('${workspaceRoot}', path.relative(workspace.rootPath!, pythonPath));
5959
}
6060
const pythonConfig = workspace.getConfiguration('python');
61-
pythonConfig.update('pythonPath', pythonPath).then(() => {
61+
let global = null;
62+
if (typeof workspace.rootPath !== 'string') {
63+
global = true;
64+
}
65+
pythonConfig.update('pythonPath', pythonPath, global).then(() => {
6266
//Done
6367
}, reason => {
6468
window.showErrorMessage(`Failed to set 'pythonPath'. Error: ${reason.message}`);

src/client/providers/setInterpreterProvider.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ export class SetInterpreterProvider implements vscode.Disposable {
5858
}
5959

6060
private setInterpreter() {
61-
if (typeof vscode.workspace.rootPath !== 'string') {
62-
return vscode.window.showErrorMessage('Please open a workspace to select the Python Interpreter');
63-
}
6461
this.presentQuickPick();
6562
}
6663
}

0 commit comments

Comments
 (0)