Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/client/interpreter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
import * as path from 'path';
import { Disposable, StatusBarAlignment, Uri, window, workspace } from 'vscode';
import { ConfigurationTarget, Disposable, StatusBarAlignment, Uri, window, workspace } from 'vscode';
import { PythonSettings } from '../common/configSettings';
import { PythonPathUpdaterService } from './configuration/pythonPathUpdaterService';
import { PythonPathUpdaterServiceFactory } from './configuration/pythonPathUpdaterServiceFactory';
Expand Down Expand Up @@ -71,9 +71,15 @@ export class InterpreterManager implements Disposable {
if (!activeWorkspace) {
return false;
}
const pythonConfig = workspace.getConfiguration('python');
const pythonPathInConfig = pythonConfig.get<string>('pythonPath', 'python');
return path.basename(pythonPathInConfig) === pythonPathInConfig;
const pythonConfig = workspace.getConfiguration('python', activeWorkspace.folderUri);
const pythonPathInConfig = pythonConfig.inspect<string>('pythonPath');
if (activeWorkspace.configTarget === ConfigurationTarget.Workspace) {
return pythonPathInConfig.workspaceValue === undefined || pythonPathInConfig.workspaceValue === 'python';
}
if (activeWorkspace.configTarget === ConfigurationTarget.WorkspaceFolder) {
return pythonPathInConfig.workspaceFolderValue === undefined || pythonPathInConfig.workspaceFolderValue === 'python';
}
return false;
}
private onConfigChanged() {
if (this.display) {
Expand Down
11 changes: 9 additions & 2 deletions src/client/interpreter/locators/services/virtualEnvService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ export function getKnownSearchPathsForVirtualEnvs(resource?: Uri): string[] {
if (venvPath) {
paths.push(untildify(venvPath));
}
if (Array.isArray(workspace.workspaceFolders) && workspace.workspaceFolders.length === 0) {
paths.push(workspace.workspaceFolders[0].uri.fsPath);
if (Array.isArray(workspace.workspaceFolders) && workspace.workspaceFolders.length > 0) {
if (resource && workspace.workspaceFolders.length > 1) {
const wkspaceFolder = workspace.getWorkspaceFolder(resource);
if (wkspaceFolder) {
paths.push(wkspaceFolder.uri.fsPath);
}
} else {
paths.push(workspace.workspaceFolders[0].uri.fsPath);
}
}
return paths;
}