Skip to content

Commit db2a776

Browse files
authored
ignore setting updates on default project selection (#360)
fixes #355 regression occurred since now settings edits were made for every project add where only project settings that differ from the default need to be added to the settings
1 parent 39e3225 commit db2a776

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/features/projectManager.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { Uri, EventEmitter, MarkdownString, Disposable } from 'vscode';
2-
import { IconPath, PythonProject } from '../api';
31
import * as path from 'path';
4-
import { PythonProjectManager, PythonProjectSettings, PythonProjectsImpl } from '../internal.api';
2+
import { Disposable, EventEmitter, MarkdownString, Uri, workspace } from 'vscode';
3+
import { IconPath, PythonProject } from '../api';
4+
import { DEFAULT_ENV_MANAGER_ID, DEFAULT_PACKAGE_MANAGER_ID } from '../common/constants';
5+
import { createSimpleDebounce } from '../common/utils/debounce';
56
import {
67
getConfiguration,
78
getWorkspaceFolders,
89
onDidChangeConfiguration,
910
onDidChangeWorkspaceFolders,
1011
} from '../common/workspace.apis';
11-
import { createSimpleDebounce } from '../common/utils/debounce';
12+
import { PythonProjectManager, PythonProjectSettings, PythonProjectsImpl } from '../internal.api';
1213
import {
1314
addPythonProjectSetting,
1415
EditProjectSettings,
@@ -108,14 +109,22 @@ export class PythonProjectManagerImpl implements PythonProjectManager {
108109
const envManagerId = getDefaultEnvManagerSetting(this);
109110
const pkgManagerId = getDefaultPkgManagerSetting(this);
110111

112+
const globalConfig = workspace.getConfiguration('python-envs', undefined);
113+
const defaultEnvManager = globalConfig.get<string>('defaultEnvManager', DEFAULT_ENV_MANAGER_ID);
114+
const defaultPkgManager = globalConfig.get<string>('defaultPackageManager', DEFAULT_PACKAGE_MANAGER_ID);
115+
111116
_projects.forEach((w) => {
112-
edits.push({ project: w, envManager: envManagerId, packageManager: pkgManagerId });
117+
// if the package manager and env manager are not the default ones, then add them to the edits
118+
if (envManagerId !== defaultEnvManager || pkgManagerId !== defaultPkgManager) {
119+
edits.push({ project: w, envManager: envManagerId, packageManager: pkgManagerId });
120+
}
113121
return this._projects.set(w.uri.toString(), w);
114122
});
115123
this._onDidChangeProjects.fire(Array.from(this._projects.values()));
116124

117-
// handle bulk edits to avoid multiple calls to the setting
118-
await addPythonProjectSetting(edits);
125+
if (edits.length > 0) {
126+
await addPythonProjectSetting(edits);
127+
}
119128
}
120129

121130
remove(projects: PythonProject | ProjectArray): void {

0 commit comments

Comments
 (0)