Skip to content

Commit

Permalink
Improved interpreter switching (#1263)
Browse files Browse the repository at this point in the history
Switching the interpreter is possible if no workspace is opened
  • Loading branch information
Kavakuo authored and DonJayamanne committed Oct 3, 2017
1 parent 24c2b66 commit 9c7a8e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
},
{
"command": "python.setInterpreter",
"title": "Select Workspace Interpreter",
"title": "Select Interpreter",
"category": "Python"
},
{
Expand Down
6 changes: 5 additions & 1 deletion src/client/interpreter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
3 changes: 0 additions & 3 deletions src/client/providers/setInterpreterProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 9c7a8e3

Please sign in to comment.