From 23efcf9b722fa9fd39a02db19c1bbc37949fe1e7 Mon Sep 17 00:00:00 2001 From: Luciana Abud <45497113+luabud@users.noreply.github.com> Date: Fri, 6 Jan 2023 14:54:37 -0800 Subject: [PATCH] Make auto indent depend on formatOnType setting value (#20480) For https://github.com/microsoft/vscode-python/issues/20479 --- 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..4e2320b42331 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); } - return inExperiment && formatOnTypeEffectiveValue; + const formatOnTypeEffectiveValue = this.getPythonSpecificEditorSection().get(FORMAT_ON_TYPE_CONFIG_SETTING); + + return formatOnTypeEffectiveValue; } private async isInAutoIndentExperiment(): Promise {