Skip to content

Commit 90cb829

Browse files
authored
Make auto indent depend on formatOnType setting value (#20480)
For #20479
1 parent e6b2752 commit 90cb829

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/client/activation/node/analysisOptions.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,19 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt
4444

4545
private async isAutoIndentEnabled() {
4646
const editorConfig = this.getPythonSpecificEditorSection();
47-
let formatOnTypeEffectiveValue = editorConfig.get(FORMAT_ON_TYPE_CONFIG_SETTING);
4847
const formatOnTypeInspect = editorConfig.inspect(FORMAT_ON_TYPE_CONFIG_SETTING);
4948
const formatOnTypeSetForPython = formatOnTypeInspect?.globalLanguageValue !== undefined;
5049

5150
const inExperiment = await this.isInAutoIndentExperiment();
52-
53-
if (inExperiment !== formatOnTypeSetForPython) {
54-
if (inExperiment) {
55-
await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, true);
56-
} else if (formatOnTypeInspect?.globalLanguageValue !== false) {
57-
await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, undefined);
58-
}
59-
60-
formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING);
51+
// only explicitly enable formatOnType for those who are in the experiment
52+
// but have not explicitly given a value for the setting
53+
if (!formatOnTypeSetForPython && inExperiment) {
54+
await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, true);
6155
}
6256

63-
return inExperiment && formatOnTypeEffectiveValue;
57+
const formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING);
58+
59+
return formatOnTypeEffectiveValue;
6460
}
6561

6662
private async isInAutoIndentExperiment(): Promise<boolean> {

0 commit comments

Comments
 (0)