Skip to content

Incorrect indentation for single line if/for/while/etc, multiline chaining statements etc #43244

Open
@johanolofsson

Description

@johanolofsson

I 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. 

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugeditor-autoindentEditor auto indentation issuesjavascriptJavaScript support issuestypescriptTypescript support issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions