Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/client/activation/node/analysisOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still checking for inExperiment, so can you clarify how are we making sure this is enabled for all users? cc/ Luciana Abud (@luabud)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to enable this to all users, just those who explicitly enable format on type. If they don't have it enabled, we still want only those who are in the experiment to experience it.

Expand Down