Skip to content

Commit

Permalink
Fixes #356: Make use of new affectsConfiguration method
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer committed Jun 4, 2018
1 parent 26b1ccf commit 2468a7b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
FormattingOptions as VFormattingOptions, TextEdit as VTextEdit, WorkspaceEdit as VWorkspaceEdit, MessageItem,
Hover as VHover,
DocumentLink as VDocumentLink, TextDocumentWillSaveEvent,
WorkspaceFolder as VWorkspaceFolder, CompletionContext as VCompletionContext
WorkspaceFolder as VWorkspaceFolder, CompletionContext as VCompletionContext, ConfigurationChangeEvent
} from 'vscode';

import {
Expand Down Expand Up @@ -2058,12 +2058,12 @@ class ConfigurationFeature implements DynamicFeature<DidChangeConfigurationRegis
}

public register(_message: RPCMessageType, data: RegistrationData<DidChangeConfigurationRegistrationOptions>): void {
let disposable = Workspace.onDidChangeConfiguration(() => {
this.onDidChangeConfiguration(data.registerOptions.section);
let disposable = Workspace.onDidChangeConfiguration((event) => {
this.onDidChangeConfiguration(data.registerOptions.section, event);
});
this._listeners.set(data.id, disposable);
if (data.registerOptions.section !== void 0) {
this.onDidChangeConfiguration(data.registerOptions.section);
this.onDidChangeConfiguration(data.registerOptions.section, undefined);
}
}

Expand All @@ -2082,13 +2082,19 @@ class ConfigurationFeature implements DynamicFeature<DidChangeConfigurationRegis
this._listeners.clear();
}

private onDidChangeConfiguration(configurationSection: string | string[] | undefined): void {
private onDidChangeConfiguration(configurationSection: string | string[] | undefined, event: ConfigurationChangeEvent | undefined): void {
let sections: string[] | undefined;
if (Is.string(configurationSection)) {
sections = [configurationSection];
} else {
sections = configurationSection;
}
if (sections !== void 0 && event !== void 0) {
let affected = sections.some((section) => event.affectsConfiguration(section));
if (!affected) {
return;
}
}
let didChangeConfiguration = (sections: string[] | undefined): void => {
if (sections === void 0) {
this._client.sendNotification(DidChangeConfigurationNotification.type, { settings: null });
Expand Down

0 comments on commit 2468a7b

Please sign in to comment.