@@ -23,6 +23,7 @@ type ActivatorInfo = { jedi: boolean; activator: ILanguageServerActivator };
23
23
@injectable ( )
24
24
export class LanguageServerExtensionActivationService implements IExtensionActivationService , Disposable {
25
25
private activatedWorkspaces = new Map < string , ILanguageServerActivator > ( ) ;
26
+ private workspaceFoldersCount = 1 ;
26
27
private currentActivator ?: ActivatorInfo ;
27
28
private readonly workspaceService : IWorkspaceService ;
28
29
private readonly output : OutputChannel ;
@@ -91,13 +92,18 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
91
92
}
92
93
93
94
protected onWorkspaceFoldersChanged ( ) {
94
- if ( this . workspaceService . workspaceFolders ! . length < this . activatedWorkspaces . size ) {
95
- //No. of workspace folders has decreased, dispose activator
95
+ if ( this . workspaceService . workspaceFolders ! . length < this . workspaceFoldersCount ) {
96
+ //If the removed workspace folder was activated, dispose its activator
97
+ this . workspaceFoldersCount += - 1 ;
96
98
const workspaceKeys = this . workspaceService . workspaceFolders ! . map ( workspaceFolder => this . getWorkspacePathKey ( workspaceFolder . uri ) ) ;
97
99
const mapKeys = Array . from ( this . activatedWorkspaces . keys ( ) ) ;
98
- const folderRemoved = mapKeys . filter ( x => workspaceKeys . indexOf ( x ) < 0 ) [ 0 ] ;
99
- this . activatedWorkspaces . get ( folderRemoved ) . dispose ( ) ;
100
- this . activatedWorkspaces . delete ( folderRemoved ) ;
100
+ const activatedfoldersRemoved = mapKeys . filter ( x => workspaceKeys . indexOf ( x ) < 0 ) ;
101
+ if ( activatedfoldersRemoved . length > 0 ) {
102
+ this . activatedWorkspaces . get ( activatedfoldersRemoved [ 0 ] ) . dispose ( ) ;
103
+ this . activatedWorkspaces . delete ( activatedfoldersRemoved [ 0 ] ) ;
104
+ }
105
+ } else {
106
+ this . workspaceFoldersCount += 1 ;
101
107
}
102
108
}
103
109
0 commit comments