Auto indent in JS, follow up #46401
Labels
editor-autoindent
Editor auto indentation issues
javascript
JavaScript support issues
on-unit-test
typescript
Typescript support issues
under-discussion
Issue is under discussion for relevance, priority, approach
This is a follow up of bug #29390 because I think the change in behavior is not what most users would like to have. I'm a big fan of single line blocks without brackets.
Yes, I know some consider this a huge security risk and bad practice, and I have a eslint looking for two liners indented without braces so I feel safe (and in 15+ years of dev I never had a bug due to that specific issue).
I don't think your editor should decide for you how you should code. @Gama11 posted a gif of how Sublime Text handles that specific issue to support all known styles at once. This probably requires a more involved solution but I would like it to be considered (at least) before being left out.
Here, for the record, I post back the gif he posted:
As you can see, when you write an if, it auto indents the line if you press Enter (previous behavior of vscode). Then if you make a single line and press enter, it will automatically deindent. But if you immediately put in a bracket instead (second example of the gif), it deindents it, effectively supporting allman style by adapting to it after the fact. This prevents the issue reported in bug #36505 that was closed by lack of an obvious solution.
But fixing the allman style and breaking instead single line blocks is not really optimal. Even more so because I believe we are more to use single line blocks that they are allman styles guys (in JS/TS).
The text was updated successfully, but these errors were encountered: