From 417d9d29b35601a2595ea1c69abad8d042fd608f Mon Sep 17 00:00:00 2001 From: Erik De Bonte Date: Mon, 28 Nov 2022 12:30:41 -0800 Subject: [PATCH] Catch exception when changing formatOnType --- src/client/activation/node/analysisOptions.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/client/activation/node/analysisOptions.ts b/src/client/activation/node/analysisOptions.ts index 467a36f293fe..dc8157cbc650 100644 --- a/src/client/activation/node/analysisOptions.ts +++ b/src/client/activation/node/analysisOptions.ts @@ -11,6 +11,7 @@ import { IExperimentService } from '../../common/types'; import { LanguageServerAnalysisOptionsBase } from '../common/analysisOptions'; import { ILanguageServerOutputChannel } from '../types'; import { LspNotebooksExperiment } from './lspNotebooksExperiment'; +import { traceWarn } from '../../logging'; const EDITOR_CONFIG_SECTION = 'editor'; const FORMAT_ON_TYPE_CONFIG_SETTING = 'formatOnType'; @@ -79,11 +80,15 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt editorConfig: WorkspaceConfiguration, value: boolean | undefined, ) { - await editorConfig.update( - FORMAT_ON_TYPE_CONFIG_SETTING, - value, - ConfigurationTarget.Global, - /* overrideInLanguage */ true, - ); + try { + await editorConfig.update( + FORMAT_ON_TYPE_CONFIG_SETTING, + value, + ConfigurationTarget.Global, + /* overrideInLanguage */ true, + ); + } catch (ex) { + traceWarn(`Failed to set formatOnType to ${value}`); + } } }