Skip to content
Merged
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
23 changes: 16 additions & 7 deletions src/features/projectManager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Uri, EventEmitter, MarkdownString, Disposable } from 'vscode';
import { IconPath, PythonProject } from '../api';
import * as path from 'path';
import { PythonProjectManager, PythonProjectSettings, PythonProjectsImpl } from '../internal.api';
import { Disposable, EventEmitter, MarkdownString, Uri, workspace } from 'vscode';
import { IconPath, PythonProject } from '../api';
import { DEFAULT_ENV_MANAGER_ID, DEFAULT_PACKAGE_MANAGER_ID } from '../common/constants';
import { createSimpleDebounce } from '../common/utils/debounce';
import {
getConfiguration,
getWorkspaceFolders,
onDidChangeConfiguration,
onDidChangeWorkspaceFolders,
} from '../common/workspace.apis';
import { createSimpleDebounce } from '../common/utils/debounce';
import { PythonProjectManager, PythonProjectSettings, PythonProjectsImpl } from '../internal.api';
import {
addPythonProjectSetting,
EditProjectSettings,
Expand Down Expand Up @@ -108,14 +109,22 @@ export class PythonProjectManagerImpl implements PythonProjectManager {
const envManagerId = getDefaultEnvManagerSetting(this);
const pkgManagerId = getDefaultPkgManagerSetting(this);

const globalConfig = workspace.getConfiguration('python-envs', undefined);
const defaultEnvManager = globalConfig.get<string>('defaultEnvManager', DEFAULT_ENV_MANAGER_ID);
const defaultPkgManager = globalConfig.get<string>('defaultPackageManager', DEFAULT_PACKAGE_MANAGER_ID);

_projects.forEach((w) => {
edits.push({ project: w, envManager: envManagerId, packageManager: pkgManagerId });
// if the package manager and env manager are not the default ones, then add them to the edits
if (envManagerId !== defaultEnvManager || pkgManagerId !== defaultPkgManager) {
edits.push({ project: w, envManager: envManagerId, packageManager: pkgManagerId });
}
return this._projects.set(w.uri.toString(), w);
});
this._onDidChangeProjects.fire(Array.from(this._projects.values()));

// handle bulk edits to avoid multiple calls to the setting
await addPythonProjectSetting(edits);
if (edits.length > 0) {
await addPythonProjectSetting(edits);
}
}

remove(projects: PythonProject | ProjectArray): void {
Expand Down