Incorrect indentation for single line if/for/while/etc, multiline chaining statements etc
See original GitHub issueI am experiencing some weird indentation issues. Not using any plugins to prettify or similar.
if (condition) {
return; // <-- correct indentation
}
if(condition)
return; // <-- incorrect indentation
Some ppl claim this should be avoided. I don’t agree. Using pair of { } for simple early exits messes up code. Putting the return on the end of the same line can be hard to read if the condition is long. This is not exclusive to return. Applies to all single lines.
same problems apply to for, while, etc.
var transformedValues =
originalValues <-- incorrect should be indented one level.
.where(condition) <-- incorrect, should be indented two levels.
.select(transform); <-- incorrect, should be indented two levels.
function someFunction() {
callToSomeOtherFunction(
variableWithLongNameWhichRequiresASeparateLine,
anotherVariableWithLongNameWhichRequiresASeparateLine);
} <-- incorrect should not be indented.
function ... <-- incorrect the rest of the file is indented.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:33
- Comments:52 (4 by maintainers)
Top Results From Across the Web
Auto-indent lines feature wrongly indents multiline chained ...
prefetch_related( statements have the wrong indent. The gray underline appears, and the tooltip warns: "PEP8: continuation line unaligned for hanging indent".
Read more >C# at Google Style Guide | styleguide
Developed from Google Java style. A maximum of one statement per line. A maximum of one assignment per statement. Indentation of 2 spaces,...
Read more >What is the proper way to format a multi-line dict in Python?
I use #3. Same for long lists, tuples, etc. It doesn't require adding any extra spaces beyond the indentations. As always, be consistent....
Read more >Visual Studio Code: Formatting Java Method Chaining
Incorrect indentation for single line if/for/while/etc multiline chaining statements etc #43244 Line after braceless if statement doesn't autoindent #41702 ...
Read more >D95168 [clang-format] Add Insert/Remove Braces option - LLVM
InsertBraces will insert braces for single line control flow statements (currently if/else/for). It currently accepts the following options:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yet another trivial error:
i don’t understand why this is labeled
feature-request
and notbug
.I’ve seen developers argue that this is not a bug, and others argue that you should use braces, and never single line indented statements (which is all wrong or absurdly opinionated).
The bizarre part is that every single other editor with auto indentation seems to do it right, including all versions of full Visual Studio, since beginning of time. I don’t get it… why can’t you just do what VS (full) does?
Yes, I can use another editor, and no, my problem isn’t lack of effort by the devs for a free product, it’s the mind blowing attitude that this is not a problem or not one worth fixing for like 5 years now.
I’m used to VS Code and otherwise love it, but it has now become second nature to fix indentation after all single-line if/else/while/for/etc. – why is this so hard to finally fix??