Skip to content

smartIndenter: Don't indent after control-flow ending statements like break; #20016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
3 commits merged into from
Nov 15, 2017

Conversation

ghost
Copy link

@ghost ghost commented Nov 14, 2017

Fixes #19973

export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean {
return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false);
function isControlFlowEndingStatement(kind: SyntaxKind) {
switch (kind) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also check that it is the last statement of the block?

e.g.:

switch(x) {
   case 1:
       if (cond)
          break;
          |
}

Copy link
Author

@ghost ghost Nov 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always dedent after a statement in a brace-less if anyway.

@ghost ghost merged commit d49491b into master Nov 15, 2017
@ghost ghost deleted the noIndentAfterBreak branch November 15, 2017 19:08
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant