@@ -86,26 +86,26 @@ import { cleanupStartupScripts } from './features/terminal/shellStartupSetupHand
8686import { TerminalActivationImpl } from './features/terminal/terminalActivationState' ;
8787import { TerminalEnvVarInjector } from './features/terminal/terminalEnvVarInjector' ;
8888import { TerminalManager , TerminalManagerImpl } from './features/terminal/terminalManager' ;
89- import { registerTerminalPackageWatcher } from './features/terminal/terminalPackageWatcher' ;
9089import { getEnvironmentForTerminal } from './features/terminal/utils' ;
9190import { openSearchSettings } from './features/views/envManagerSearch' ;
9291import { EnvManagerView } from './features/views/envManagersView' ;
9392import { ProjectView } from './features/views/projectView' ;
9493import { PythonStatusBarImpl } from './features/views/pythonStatusBar' ;
9594import { updateViewsAndStatus } from './features/views/revealHandler' ;
9695import { TemporaryStateManager } from './features/views/temporaryStateManager' ;
97- import { ProjectItem , PythonEnvTreeItem } from './features/views/treeViewItems' ;
96+ import { PythonEnvTreeItem } from './features/views/treeViewItems' ;
9897import { collectEnvironmentInfo , getEnvManagerAndPackageManagerConfigLevels , runPetInTerminalImpl } from './helpers' ;
9998import { EnvironmentManagers , ProjectCreators , PythonProjectManager } from './internal.api' ;
100- import { registerSystemPythonFeatures } from './managers/builtin/main' ;
10199import { registerInlineScriptFeatures } from './managers/builtin/inlineScript/main' ;
100+ import { registerSystemPythonFeatures } from './managers/builtin/main' ;
102101import { SysPythonManager } from './managers/builtin/sysPythonManager' ;
103102import {
104103 createNativePythonFinder ,
105104 getNativePythonToolsPathAndSource ,
106105 getNativePythonToolsVersion ,
107106 NativePythonFinder ,
108107} from './managers/common/nativePythonFinder' ;
108+ import { registerPackageWatchers } from './managers/common/packageWatcher' ;
109109import { IDisposable } from './managers/common/types' ;
110110import { registerCondaFeatures } from './managers/conda/main' ;
111111import { registerPipenvFeatures } from './managers/pipenv/main' ;
@@ -364,17 +364,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
364364 } ) ;
365365 } ) ,
366366 commands . registerCommand ( 'python-envs.removePythonProject' , async ( item ) => {
367- // Clear environment association before removing project
368- if ( item instanceof ProjectItem ) {
369- const uri = item . project . uri ;
370- const manager = envManagers . getEnvironmentManager ( uri ) ;
371- if ( manager ) {
372- manager . set ( uri , undefined ) ;
373- } else {
374- traceError ( `No environment manager found for ${ uri . fsPath } ` ) ;
375- }
376- }
377- await removePythonProject ( item , projectManager ) ;
367+ await removePythonProject ( item , projectManager , envManagers ) ;
378368 } ) ,
379369 commands . registerCommand ( 'python-envs.clearCache' , async ( ) => {
380370 await clearPersistentState ( ) ;
@@ -672,6 +662,8 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
672662 safeRegister ( 'shellStartupVars' , shellStartupVarsMgr . initialize ( ) ) ,
673663 ] ) ;
674664
665+ context . subscriptions . push ( registerPackageWatchers ( envManagers , terminalActivation , outputChannel ) ) ;
666+
675667 failureStage = 'envSelection' ;
676668 stageWatch . reset ( ) ;
677669 await applyInitialEnvironmentSelection (
@@ -683,11 +675,6 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
683675 globalScopeDeferredRef ,
684676 ) ;
685677
686- // Register manager-agnostic terminal watcher for package-modifying commands
687- failureStage = 'terminalWatcher' ;
688- stageWatch . reset ( ) ;
689- registerTerminalPackageWatcher ( api , terminalActivation , outputChannel , context . subscriptions ) ;
690-
691678 // Register listener for interpreter settings changes for interpreter re-selection
692679 failureStage = 'settingsListener' ;
693680 stageWatch . reset ( ) ;
0 commit comments