|
1 | | -import { Uri, EventEmitter, MarkdownString, Disposable } from 'vscode'; |
2 | | -import { IconPath, PythonProject } from '../api'; |
3 | 1 | 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'; |
5 | 6 | import { |
6 | 7 | getConfiguration, |
7 | 8 | getWorkspaceFolders, |
8 | 9 | onDidChangeConfiguration, |
9 | 10 | onDidChangeWorkspaceFolders, |
10 | 11 | } from '../common/workspace.apis'; |
11 | | -import { createSimpleDebounce } from '../common/utils/debounce'; |
| 12 | +import { PythonProjectManager, PythonProjectSettings, PythonProjectsImpl } from '../internal.api'; |
12 | 13 | import { |
13 | 14 | addPythonProjectSetting, |
14 | 15 | EditProjectSettings, |
@@ -108,14 +109,22 @@ export class PythonProjectManagerImpl implements PythonProjectManager { |
108 | 109 | const envManagerId = getDefaultEnvManagerSetting(this); |
109 | 110 | const pkgManagerId = getDefaultPkgManagerSetting(this); |
110 | 111 |
|
| 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 | + |
111 | 116 | _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 | + } |
113 | 121 | return this._projects.set(w.uri.toString(), w); |
114 | 122 | }); |
115 | 123 | this._onDidChangeProjects.fire(Array.from(this._projects.values())); |
116 | 124 |
|
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 | + } |
119 | 128 | } |
120 | 129 |
|
121 | 130 | remove(projects: PythonProject | ProjectArray): void { |
|
0 commit comments