public onDidChangeSettings()

in Extension/src/LanguageServer/client.ts [1605:1685]


    public onDidChangeSettings(event: vscode.ConfigurationChangeEvent, isFirstClient: boolean): { [key: string]: string } {
        this.sendAllSettings();
        const changedSettings: { [key: string]: string } = this.settingsTracker.getChangedSettings();
        this.notifyWhenLanguageClientReady(() => {
            if (Object.keys(changedSettings).length > 0) {
                if (isFirstClient) {
                    if (changedSettings["commentContinuationPatterns"]) {
                        updateLanguageConfigurations();
                    }
                    if (changedSettings["loggingLevel"]) {
                        const oldLoggingLevelLogged: boolean = !!this.loggingLevel && this.loggingLevel !== "None" && this.loggingLevel !== "Error";
                        const newLoggingLevel: string | undefined = changedSettings["loggingLevel"];
                        this.loggingLevel = newLoggingLevel;
                        const newLoggingLevelLogged: boolean = !!newLoggingLevel && newLoggingLevel !== "None" && newLoggingLevel !== "Error";
                        if (oldLoggingLevelLogged || newLoggingLevelLogged) {
                            const out: logger.Logger = logger.getOutputChannelLogger();
                            out.appendLine(localize({ key: "loggingLevel.changed", comment: ["{0} is the setting name 'loggingLevel', {1} is a string value such as 'Debug'"] }, "{0} has changed to: {1}", "loggingLevel", changedSettings["loggingLevel"]));
                        }
                    }
                    const settings: CppSettings = new CppSettings();
                    if (changedSettings["formatting"]) {
                        const folderSettings: CppSettings = new CppSettings(this.RootUri);
                        if (folderSettings.formattingEngine !== "Disabled") {
                            // Because the setting is not a bool, changes do not always imply we need to
                            // register/unregister the providers.
                            if (!this.documentFormattingProviderDisposable) {
                                this.documentFormattingProviderDisposable = vscode.languages.registerDocumentFormattingEditProvider(this.documentSelector, new DocumentFormattingEditProvider(this));
                            }
                            if (!this.formattingRangeProviderDisposable) {
                                this.formattingRangeProviderDisposable = vscode.languages.registerDocumentRangeFormattingEditProvider(this.documentSelector, new DocumentRangeFormattingEditProvider(this));
                            }
                            if (!this.onTypeFormattingProviderDisposable) {
                                this.onTypeFormattingProviderDisposable = vscode.languages.registerOnTypeFormattingEditProvider(this.documentSelector, new OnTypeFormattingEditProvider(this), ";", "}", "\n");
                            }
                        } else {
                            if (this.documentFormattingProviderDisposable) {
                                this.documentFormattingProviderDisposable.dispose();
                                this.documentFormattingProviderDisposable = undefined;
                            }
                            if (this.formattingRangeProviderDisposable) {
                                this.formattingRangeProviderDisposable.dispose();
                                this.formattingRangeProviderDisposable = undefined;
                            }
                            if (this.onTypeFormattingProviderDisposable) {
                                this.onTypeFormattingProviderDisposable.dispose();
                                this.onTypeFormattingProviderDisposable = undefined;
                            }
                        }
                    }
                    if (changedSettings["codeFolding"]) {
                        if (settings.codeFolding) {
                            this.codeFoldingProvider = new FoldingRangeProvider(this);
                            this.codeFoldingProviderDisposable = vscode.languages.registerFoldingRangeProvider(this.documentSelector, this.codeFoldingProvider);
                        } else if (this.codeFoldingProviderDisposable) {
                            this.codeFoldingProviderDisposable.dispose();
                            this.codeFoldingProviderDisposable = undefined;
                            this.codeFoldingProvider = undefined;
                        }
                    }
                    if (changedSettings["enhancedColorization"]) {
                        if (settings.enhancedColorization && this.semanticTokensLegend) {
                            this.semanticTokensProvider = new SemanticTokensProvider(this);
                            this.semanticTokensProviderDisposable = vscode.languages.registerDocumentSemanticTokensProvider(this.documentSelector, this.semanticTokensProvider, this.semanticTokensLegend);
                        } else if (this.semanticTokensProviderDisposable) {
                            this.semanticTokensProviderDisposable.dispose();
                            this.semanticTokensProviderDisposable = undefined;
                            this.semanticTokensProvider = undefined;
                        }
                    }
                    // if addNodeAddonIncludePaths was turned on but no includes have been found yet then 1) presume that nan
                    // or node-addon-api was installed so prompt for reload.
                    if (changedSettings["addNodeAddonIncludePaths"] && settings.addNodeAddonIncludePaths && this.configuration.nodeAddonIncludesFound() === 0) {
                        util.promptForReloadWindowDueToSettingsChange();
                    }
                }
                this.configuration.onDidChangeSettings();
                telemetry.logLanguageServerEvent("CppSettingsChange", changedSettings, undefined);
            }
        });
        return changedSettings;
    }