Skip to content

Conversation

debonte
Copy link

@debonte debonte commented Aug 23, 2022

Updated NodeLanguageServerAnalysisOptions to pass a new autoIndentSupport initialization option to Pylance. This is set to true if the user is in the "pylanceAutoIndent" experiment and editor.formatOnType is enabled.

Additionally, if the user is in the experiment and formatOnType is not set in the Python-specific config settings, we will set it to true. Users can opt out of the experiment by setting it to false in the [python] settings, like this:

"[python]": {
    "editor.formatOnType": false
}

If the user is not in the experiment, we will unset the Python-specific formatOnType setting (if present), unless it is set to false. I was concerned that users might opt-out and then get removed from and added back into the experiment. If that happens, I don't want them to need to opt out again. Happy to remove this logic if this scenario won't happen.

Since this code is temporary, I chose not to integrate it into PythonSettings in any way. Assuming we decide to enable this feature for everyone at some point, we'll remove this code and change the default of editor.formatOnType for Pylance users to true via Pylance's package.json:

"configurationDefaults": {
    "[python]": {
        "editor.formatOnType": true
    }
},

Users running internal (-dev) builds of Pylance will be treated as bring in the experiment treatment group. Otherwise we would always unset editor.formatOnType for them which would make testing awkward.

Also includes a related change in LanguageClientMiddleware to return the Python view of editor.formatOnType so Pylance can include it in its settings telemetry event.

@debonte debonte requested review from karrtikr and luabud August 23, 2022 01:06
@debonte debonte added the no-changelog No news entry required label Aug 23, 2022
@karrtikr karrtikr requested a review from karthiknadig August 23, 2022 23:59
karthiknadig
karthiknadig previously approved these changes Aug 24, 2022
@debonte debonte merged commit b68bcd7 into microsoft:main Aug 25, 2022
@debonte debonte deleted the formatOnType branch August 25, 2022 00:55
wesm pushed a commit to posit-dev/positron that referenced this pull request Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants