Skip to content

Commit 1e77898

Browse files
author
Kartik Raj
committed
Corrected functionality
1 parent 45b55f0 commit 1e77898

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/client/activation/activationService.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type ActivatorInfo = { jedi: boolean; activator: ILanguageServerActivator };
2323
@injectable()
2424
export class LanguageServerExtensionActivationService implements IExtensionActivationService, Disposable {
2525
private activatedWorkspaces = new Map<string, ILanguageServerActivator>();
26+
private workspaceFoldersCount = 1;
2627
private currentActivator?: ActivatorInfo;
2728
private readonly workspaceService: IWorkspaceService;
2829
private readonly output: OutputChannel;
@@ -91,13 +92,18 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
9192
}
9293

9394
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;
9698
const workspaceKeys = this.workspaceService.workspaceFolders!.map(workspaceFolder => this.getWorkspacePathKey(workspaceFolder.uri));
9799
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;
101107
}
102108
}
103109

src/client/activation/jedi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class JediExtensionActivator implements ILanguageServerActivator {
3333
this.documentSelector = PYTHON;
3434
}
3535

36-
public async activate(_resource: Resource): Promise<void> {
36+
public async activate(resource: Resource): Promise<void> {
3737
const context = this.context;
3838

3939
const jediFactory = (this.jediFactory = new JediFactory(context.asAbsolutePath('.'), this.serviceManager));
@@ -89,7 +89,7 @@ export class JediExtensionActivator implements ILanguageServerActivator {
8989
const symbolProvider = new JediSymbolProvider(serviceContainer, jediFactory);
9090
context.subscriptions.push(languages.registerDocumentSymbolProvider(this.documentSelector, symbolProvider));
9191

92-
const pythonSettings = this.serviceManager.get<IConfigurationService>(IConfigurationService).getSettings();
92+
const pythonSettings = this.serviceManager.get<IConfigurationService>(IConfigurationService).getSettings(resource);
9393
if (pythonSettings.devOptions.indexOf('DISABLE_SIGNATURE') === -1) {
9494
context.subscriptions.push(
9595
languages.registerSignatureHelpProvider(

src/client/activation/languageServer/analysisOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class LanguageServerAnalysisOptions implements ILanguageServerAnalysisOpt
7979
properties['DatabasePath'] = path.join(this.context.extensionPath, this.languageServerFolder);
8080

8181
let searchPaths = interpreterData ? interpreterData.searchPaths.split(path.delimiter) : [];
82-
const settings = this.configuration.getSettings();
82+
const settings = this.configuration.getSettings(this.resource);
8383
if (settings.autoComplete) {
8484
const extraPaths = settings.autoComplete.extraPaths;
8585
if (extraPaths && extraPaths.length > 0) {

0 commit comments

Comments
 (0)