Skip to content

Add space after '?' only for conditional operators #2110

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
merged 3 commits into from
Feb 24, 2015
Merged

Conversation

vladima
Copy link
Contributor

@vladima vladima commented Feb 23, 2015

Fixes #2080

@@ -217,7 +221,8 @@ module ts.formatting {
this.NoSpaceBeforeColon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ColonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
this.NoSpaceBeforeQMark = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.QuestionToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
this.SpaceAfterColon = new Rule(RuleDescriptor.create3(SyntaxKind.ColonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Space));
this.SpaceAfterQMark = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Space));
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand; why didn't this catch that originally?

// insert space after '?' only when it is used in conditional operator
public SpaceAfterQMarkInConditionalOperator: Rule;
// in other cases there should be no space between '?' and next token
public NoSpaceAfterQMark: Rule;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't abbreviate QuestionMark to QMark.

👍

////var x=true?1:2
format.document();
goTo.bof();
verify.currentLineContentIs("var x = true ? 1 : 2");;
Copy link
Member

Choose a reason for hiding this comment

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

;; not that it really matters

@DanielRosenwasser
Copy link
Member

👍

1 similar comment
@JsonFreeman
Copy link
Contributor

👍

vladima added a commit that referenced this pull request Feb 24, 2015
Add space after '?' only for conditional operators
@vladima vladima merged commit 55dafb5 into master Feb 24, 2015
@vladima vladima deleted the formattingQMark branch February 24, 2015 05:19
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
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.

Formatter inserts extra space after ? in optional signatures
5 participants