Skip to content

Commit

Permalink
Corrected functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Feb 1, 2019
1 parent 45b55f0 commit 1e77898
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions src/client/activation/activationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ActivatorInfo = { jedi: boolean; activator: ILanguageServerActivator };
@injectable()
export class LanguageServerExtensionActivationService implements IExtensionActivationService, Disposable {
private activatedWorkspaces = new Map<string, ILanguageServerActivator>();
private workspaceFoldersCount = 1;
private currentActivator?: ActivatorInfo;
private readonly workspaceService: IWorkspaceService;
private readonly output: OutputChannel;
Expand Down Expand Up @@ -91,13 +92,18 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
}

protected onWorkspaceFoldersChanged() {
if (this.workspaceService.workspaceFolders!.length < this.activatedWorkspaces.size) {
//No. of workspace folders has decreased, dispose activator
if (this.workspaceService.workspaceFolders!.length < this.workspaceFoldersCount) {
//If the removed workspace folder was activated, dispose its activator
this.workspaceFoldersCount += -1;
const workspaceKeys = this.workspaceService.workspaceFolders!.map(workspaceFolder => this.getWorkspacePathKey(workspaceFolder.uri));
const mapKeys = Array.from(this.activatedWorkspaces.keys());
const folderRemoved = mapKeys.filter(x => workspaceKeys.indexOf(x) < 0)[0];
this.activatedWorkspaces.get(folderRemoved).dispose();
this.activatedWorkspaces.delete(folderRemoved);
const activatedfoldersRemoved = mapKeys.filter(x => workspaceKeys.indexOf(x) < 0);
if (activatedfoldersRemoved.length > 0) {
this.activatedWorkspaces.get(activatedfoldersRemoved[0]).dispose();
this.activatedWorkspaces.delete(activatedfoldersRemoved[0]);
}
} else {
this.workspaceFoldersCount += 1;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/activation/jedi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class JediExtensionActivator implements ILanguageServerActivator {
this.documentSelector = PYTHON;
}

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

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

const pythonSettings = this.serviceManager.get<IConfigurationService>(IConfigurationService).getSettings();
const pythonSettings = this.serviceManager.get<IConfigurationService>(IConfigurationService).getSettings(resource);
if (pythonSettings.devOptions.indexOf('DISABLE_SIGNATURE') === -1) {
context.subscriptions.push(
languages.registerSignatureHelpProvider(
Expand Down
2 changes: 1 addition & 1 deletion src/client/activation/languageServer/analysisOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class LanguageServerAnalysisOptions implements ILanguageServerAnalysisOpt
properties['DatabasePath'] = path.join(this.context.extensionPath, this.languageServerFolder);

let searchPaths = interpreterData ? interpreterData.searchPaths.split(path.delimiter) : [];
const settings = this.configuration.getSettings();
const settings = this.configuration.getSettings(this.resource);
if (settings.autoComplete) {
const extraPaths = settings.autoComplete.extraPaths;
if (extraPaths && extraPaths.length > 0) {
Expand Down

0 comments on commit 1e77898

Please sign in to comment.