Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make sure to listen for all settings changes. #484

Merged
merged 3 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/_server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ function run() {
const { uri, languageId } = params;
const fileEnabled = uri ? !await isUriExcluded(uri) : undefined;
const settings = await getActiveUriSettings(uri);
const languageEnabled = languageId && uri ? await isLanguageEnabled({ uri, languageId }, settings) : undefined;
return {
languageEnabled: languageId && uri ? await isLanguageEnabled({ uri, languageId }, settings) : undefined,
languageEnabled,
fileEnabled,
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function handlerApplyTextEdits(client: LanguageClient) {
window.showInformationMessage('Spelling changes are outdated and cannot be applied to the document.');
}
const propertyFixSpellingWithRenameProvider: SpellCheckerSettingsProperties = 'fixSpellingWithRenameProvider';
const cfg = workspace.getConfiguration(CSpellSettings.sectionCSpell);
const cfg = workspace.getConfiguration(Settings.sectionCSpell);
if (cfg.get(propertyFixSpellingWithRenameProvider) && edits.length === 1) {
console.log(`${propertyFixSpellingWithRenameProvider} Enabled`);
const edit = edits[0];
Expand Down
17 changes: 16 additions & 1 deletion packages/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { performance, toMilliseconds } from './util/perf';
performance.mark('cspell_start_extension');
import * as path from 'path';
performance.mark('import 1');
import {setEnableSpellChecking} from './settings';
import {setEnableSpellChecking, sectionCSpell} from './settings';
performance.mark('import 2');
import * as settings from './settings';
performance.mark('import 3');
Expand Down Expand Up @@ -152,8 +152,23 @@ export async function activate(context: ExtensionContext): Promise<ExtensionApi>
vscode.commands.registerCommand('cSpell.disableCurrentLanguage', commands.disableCurrentLanguage),
vscode.commands.registerCommand('cSpell.logPerfTimeline', dumpPerfTimeline),
settings.watchSettingsFiles(triggerGetSettings),

/*
* We need to listen for all change events and see of `cSpell` section changed.
* When it does, we have to trigger the server to fetch the settings again.
* This is to handle a bug in the language-server synchronize configuration. It will not synchronize
* if the section didn't already exist. This leads to a poor user experience in situations like
* adding a word to be ignored for the first time.
*/
vscode.workspace.onDidChangeConfiguration(handleOnDidChangeConfiguration),
);

function handleOnDidChangeConfiguration(event: vscode.ConfigurationChangeEvent) {
if (event.affectsConfiguration(sectionCSpell)) {
triggerGetSettings();
}
}

// infoViewer.activate(context, client);
settingsViewer.activate(context, client);

Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/settings/CSpellSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { unique, uniqueFilter } from '../util';

const currentSettingsFileVersion = '0.1';

export const sectionCSpell = 'cSpell';

export const defaultFileName = 'cSpell.json';

export interface CSpellSettings extends CSpellUserSettingsWithComments {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as vscode from 'vscode';
import { CSpellClient } from './client';
import * as infoViewer from './infoViewer';
import { isSupportedUri, isSupportedDoc } from './util';
import { sectionCSpell } from './settings/CSpellSettings';
import { sectionCSpell } from './settings';


export function initStatusBar(context: ExtensionContext, client: CSpellClient) {
Expand Down