You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
No. On type formatting is not enabled by default, and will only affect the previous line (the one you hit enter from). Without the language server enabled:
If the "correct" behavior is to indent after a line continuation, then I think that first regex in onEnterRules needs to be modified.
The only sort of indention that the LS does is the : block formatter, which is a 1:1 port from the extension and does do the extra indent. I think it's only done in on-type because onEnterRules isn't powerful enough.
It could technically be done inside of the onTypeFormat handler, but it would need to be reimplemented in the extension too (and then wouldn't be available to most people, because most people don't enable on-type).
It could handle it, but it shouldn't. All of the rules on when to add an indent on an enter are produced by those onEnterRules, which IIRC is the standard way in VSC to implement it per-language, and will apply to all users, not just those who change the editor-wide formatOnType setting.
Adding a one-off exception could be done, but would then need to be reimplemented in the extension's line formatter too. And IMO, this sort of auto-indent is not the same thing as on-type formatting.
Activity
DonJayamanne commentedon Nov 12, 2018
From Andreas Mueller (@amueller) on November 10, 2018 20:55
duplicate of #481?
DonJayamanne commentedon Nov 12, 2018
Not a dup
DonJayamanne commentedon Nov 12, 2018
From Andreas Mueller (@amueller) on November 11, 2018 1:1
Hmm I guess this is a separate case that's not listed?
DonJayamanne commentedon Nov 12, 2018
From Clemens Brunner (@cbrnr) on November 12, 2018 8:5
#481 is certainly related because it also concerns proper PEP8-style indentation.
jakebailey commentedon Nov 12, 2018
Are you sure this is a language server issue? IIRC the extension is the one in control of indent on enter via those hardcoded regexes in
extension.ts.jakebailey commentedon Nov 12, 2018
https://github.com/Microsoft/vscode-python/blob/d0c239fcc78fee9a05713ced15b08e6806affc24/src/client/extension.ts#L121-L140
DonJayamanne commentedon Nov 12, 2018
Doesn't LS handle this via format on type?
How else would the LS resolve microsoft/vscode-python#481
jakebailey commentedon Nov 12, 2018
No. On type formatting is not enabled by default, and will only affect the previous line (the one you hit enter from). Without the language server enabled:
If the "correct" behavior is to indent after a line continuation, then I think that first regex in
onEnterRulesneeds to be modified.jakebailey commentedon Nov 12, 2018
The only sort of indention that the LS does is the
:block formatter, which is a 1:1 port from the extension and does do the extra indent. I think it's only done in on-type becauseonEnterRulesisn't powerful enough.It could technically be done inside of the onTypeFormat handler, but it would need to be reimplemented in the extension too (and then wouldn't be available to most people, because most people don't enable on-type).
jakebailey commentedon Nov 12, 2018
Sorry, I take that back, the
:formatter is triggered on:(duh), so doesn't involve theonEnterRules, because:isn't\n. Brainfart.DonJayamanne commentedon Nov 12, 2018
Ok, I'm confused, is this something that the language server can handle or not?
jakebailey commentedon Nov 12, 2018
It could handle it, but it shouldn't. All of the rules on when to add an indent on an enter are produced by those
onEnterRules, which IIRC is the standard way in VSC to implement it per-language, and will apply to all users, not just those who change the editor-wideformatOnTypesetting.Adding a one-off exception could be done, but would then need to be reimplemented in the extension's line formatter too. And IMO, this sort of auto-indent is not the same thing as on-type formatting.
amueller commentedon Nov 12, 2018
btw I think the cases in microsoft/vscode-python#481 are more important since using
/for line-continuation is discouraged:https://www.python.org/dev/peps/pep-0008/#maximum-line-length