From 84442b9bbad35eee5bccbf9f1d2298101a38c0f8 Mon Sep 17 00:00:00 2001 From: luabud Date: Fri, 6 Jan 2023 13:08:41 -0800 Subject: [PATCH 1/2] Make auto indent depend on formatOnType setting value --- src/client/activation/node/analysisOptions.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/client/activation/node/analysisOptions.ts b/src/client/activation/node/analysisOptions.ts index dc8157cbc650..c02b6abd8085 100644 --- a/src/client/activation/node/analysisOptions.ts +++ b/src/client/activation/node/analysisOptions.ts @@ -44,23 +44,19 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt private async isAutoIndentEnabled() { const editorConfig = this.getPythonSpecificEditorSection(); - let formatOnTypeEffectiveValue = editorConfig.get(FORMAT_ON_TYPE_CONFIG_SETTING); const formatOnTypeInspect = editorConfig.inspect(FORMAT_ON_TYPE_CONFIG_SETTING); const formatOnTypeSetForPython = formatOnTypeInspect?.globalLanguageValue !== undefined; const inExperiment = await this.isInAutoIndentExperiment(); - - if (inExperiment !== formatOnTypeSetForPython) { - if (inExperiment) { - await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, true); - } else if (formatOnTypeInspect?.globalLanguageValue !== false) { - await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, undefined); - } - - formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING); + // only explicitly enable formatOnType for those who are in the experiment + // but have not explicitly given a value for the setting + if(!formatOnTypeSetForPython && inExperiment){ + await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, true); } + + let formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING); - return inExperiment && formatOnTypeEffectiveValue; + return formatOnTypeEffectiveValue; } private async isInAutoIndentExperiment(): Promise { From 60de53ab7ececd5d9bf3c731eb848de6492c4053 Mon Sep 17 00:00:00 2001 From: luabud Date: Fri, 6 Jan 2023 13:30:33 -0800 Subject: [PATCH 2/2] Format file --- src/client/activation/node/analysisOptions.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/activation/node/analysisOptions.ts b/src/client/activation/node/analysisOptions.ts index c02b6abd8085..4e2320b42331 100644 --- a/src/client/activation/node/analysisOptions.ts +++ b/src/client/activation/node/analysisOptions.ts @@ -48,13 +48,13 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt const formatOnTypeSetForPython = formatOnTypeInspect?.globalLanguageValue !== undefined; const inExperiment = await this.isInAutoIndentExperiment(); - // only explicitly enable formatOnType for those who are in the experiment - // but have not explicitly given a value for the setting - if(!formatOnTypeSetForPython && inExperiment){ + // only explicitly enable formatOnType for those who are in the experiment + // but have not explicitly given a value for the setting + if (!formatOnTypeSetForPython && inExperiment) { await NodeLanguageServerAnalysisOptions.setPythonSpecificFormatOnType(editorConfig, true); } - - let formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING); + + const formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING); return formatOnTypeEffectiveValue; }