Skip to content

Commit 4ee6050

Browse files
authored
Catch exceptions when changing formatOnType setting (#20285)
1 parent 133a8e8 commit 4ee6050

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/client/activation/node/analysisOptions.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { IExperimentService } from '../../common/types';
1111
import { LanguageServerAnalysisOptionsBase } from '../common/analysisOptions';
1212
import { ILanguageServerOutputChannel } from '../types';
1313
import { LspNotebooksExperiment } from './lspNotebooksExperiment';
14+
import { traceWarn } from '../../logging';
1415

1516
const EDITOR_CONFIG_SECTION = 'editor';
1617
const FORMAT_ON_TYPE_CONFIG_SETTING = 'formatOnType';
@@ -79,11 +80,15 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt
7980
editorConfig: WorkspaceConfiguration,
8081
value: boolean | undefined,
8182
) {
82-
await editorConfig.update(
83-
FORMAT_ON_TYPE_CONFIG_SETTING,
84-
value,
85-
ConfigurationTarget.Global,
86-
/* overrideInLanguage */ true,
87-
);
83+
try {
84+
await editorConfig.update(
85+
FORMAT_ON_TYPE_CONFIG_SETTING,
86+
value,
87+
ConfigurationTarget.Global,
88+
/* overrideInLanguage */ true,
89+
);
90+
} catch (ex) {
91+
traceWarn(`Failed to set formatOnType to ${value}`);
92+
}
8893
}
8994
}

0 commit comments

Comments
 (0)