Skip to content

Commit 40e85a4

Browse files
authored
fix: bugs where env deletion or creation are not recorded (#362)
1 parent db2a776 commit 40e85a4

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

src/extension.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,13 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
9595
const terminalActivation = new TerminalActivationImpl();
9696
const shellEnvsProviders = createShellEnvProviders();
9797
const shellStartupProviders = createShellStartupProviders();
98-
const shellStartupVarsMgr = new ShellStartupActivationVariablesManagerImpl(
99-
context.environmentVariableCollection,
100-
shellEnvsProviders,
101-
envManagers,
102-
);
98+
10399
const terminalManager: TerminalManager = new TerminalManagerImpl(
104100
terminalActivation,
105101
shellEnvsProviders,
106102
shellStartupProviders,
107103
);
108-
context.subscriptions.push(terminalActivation, terminalManager, shellStartupVarsMgr);
104+
context.subscriptions.push(terminalActivation, terminalManager);
109105

110106
const projectCreators: ProjectCreators = new ProjectCreatorsImpl();
111107
context.subscriptions.push(
@@ -125,8 +121,14 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
125121
workspaceView.initialize();
126122

127123
const monitoredTerminals = new Map<Terminal, PythonEnvironment>();
124+
const shellStartupVarsMgr = new ShellStartupActivationVariablesManagerImpl(
125+
context.environmentVariableCollection,
126+
shellEnvsProviders,
127+
api,
128+
);
128129

129130
context.subscriptions.push(
131+
shellStartupVarsMgr,
130132
registerCompletionProvider(envManagers),
131133
registerTools('python_environment', new GetEnvironmentInfoTool(api, envManagers)),
132134
registerTools('python_install_package', new InstallPackageTool(api)),

src/features/views/projectView.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ import {
1010
window,
1111
} from 'vscode';
1212
import { PythonEnvironment } from '../../api';
13+
import { ProjectViews } from '../../common/localize';
14+
import { createSimpleDebounce } from '../../common/utils/debounce';
15+
import { onDidChangeConfiguration } from '../../common/workspace.apis';
1316
import { EnvironmentManagers, PythonProjectManager } from '../../internal.api';
1417
import {
15-
ProjectTreeItem,
16-
ProjectItem,
17-
ProjectEnvironment,
18-
ProjectPackageRootTreeItem,
19-
ProjectTreeItemKind,
18+
GlobalProjectItem,
2019
NoProjectEnvironment,
20+
ProjectEnvironment,
2121
ProjectEnvironmentInfo,
22+
ProjectItem,
2223
ProjectPackage,
2324
ProjectPackageRootInfoTreeItem,
24-
GlobalProjectItem,
25+
ProjectPackageRootTreeItem,
26+
ProjectTreeItem,
27+
ProjectTreeItemKind,
2528
} from './treeViewItems';
26-
import { onDidChangeConfiguration } from '../../common/workspace.apis';
27-
import { createSimpleDebounce } from '../../common/utils/debounce';
28-
import { ProjectViews } from '../../common/localize';
2929

3030
export class ProjectView implements TreeDataProvider<ProjectTreeItem> {
3131
private treeView: TreeView<ProjectTreeItem>;
@@ -171,7 +171,7 @@ export class ProjectView implements TreeDataProvider<ProjectTreeItem> {
171171
];
172172
}
173173

174-
const environment = await manager?.get(uri);
174+
const environment = await this.envManagers.getEnvironment(uri);
175175
if (!environment) {
176176
return [
177177
new NoProjectEnvironment(

src/managers/builtin/venvManager.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ProgressLocation, Uri, LogOutputChannel, EventEmitter, MarkdownString, ThemeIcon, l10n } from 'vscode';
1+
import * as path from 'path';
2+
import { EventEmitter, l10n, LogOutputChannel, MarkdownString, ProgressLocation, ThemeIcon, Uri } from 'vscode';
23
import {
34
CreateEnvironmentOptions,
45
CreateEnvironmentScope,
@@ -17,6 +18,12 @@ import {
1718
ResolveEnvironmentContext,
1819
SetEnvironmentScope,
1920
} from '../../api';
21+
import { PYTHON_EXTENSION_ID } from '../../common/constants';
22+
import { VenvManagerStrings } from '../../common/localize';
23+
import { createDeferred, Deferred } from '../../common/utils/deferred';
24+
import { showErrorMessage, withProgress } from '../../common/window.apis';
25+
import { NativePythonFinder } from '../common/nativePythonFinder';
26+
import { getLatest, shortVersion, sortEnvironments } from '../common/utils';
2027
import {
2128
clearVenvCache,
2229
createPythonVenv,
@@ -32,13 +39,6 @@ import {
3239
setVenvForWorkspace,
3340
setVenvForWorkspaces,
3441
} from './venvUtils';
35-
import * as path from 'path';
36-
import { NativePythonFinder } from '../common/nativePythonFinder';
37-
import { PYTHON_EXTENSION_ID } from '../../common/constants';
38-
import { createDeferred, Deferred } from '../../common/utils/deferred';
39-
import { getLatest, shortVersion, sortEnvironments } from '../common/utils';
40-
import { showErrorMessage, withProgress } from '../../common/window.apis';
41-
import { VenvManagerStrings } from '../../common/localize';
4242

4343
export class VenvManager implements EnvironmentManager {
4444
private collection: PythonEnvironment[] = [];
@@ -215,7 +215,7 @@ export class VenvManager implements EnvironmentManager {
215215
if (this.skipWatcherRefresh) {
216216
return;
217217
}
218-
return this.internalRefresh(undefined, false, VenvManagerStrings.venvRefreshing);
218+
return this.internalRefresh(undefined, true, VenvManagerStrings.venvRefreshing);
219219
}
220220

221221
private async internalRefresh(

0 commit comments

Comments
 (0)