fix: Improve contextual spacing for if statements when ifStatement.sp…#727
Open
AaronLieberman wants to merge 1 commit intodprint:mainfrom
Open
fix: Improve contextual spacing for if statements when ifStatement.sp…#727AaronLieberman wants to merge 1 commit intodprint:mainfrom
AaronLieberman wants to merge 1 commit intodprint:mainfrom
Conversation
…aceAround: true
When ifStatement.spaceAround is true, make sure the spaces around parens are right based on the context of where the paren lies.
The change is to only add the space if the open paren is not at the end of a line. We do that on the opening paren by adding a Signal::SpaceOrNewLine which allows the system to add the space if it needs to for purposes of word wrap, otherwise ommitting it. For the close paren, we add the space if we're not the first token on the line.
The impetus for this was the case where an opening paren for an if statement control block was the last character on a line, or a closing paren was the first.
For example: (where lineWidth: 40)
```
if (
somereallylongidentifier
<= anotherreallylongidentifier
) {
}
```
The above case was getting formatted with an extra space at the end of the if statement line and an extra space at the start of the close paren line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…aceAround: true
When ifStatement.spaceAround is true, make sure the spaces around parens are right based on the context of where the paren lies.
The change is to only add the space if the open paren is not at the end of a line. We do that on the opening paren by adding a Signal::SpaceOrNewLine which allows the system to add the space if it needs to for purposes of word wrap, otherwise ommitting it. For the close paren, we add the space if we're not the first token on the line.
The impetus for this was the case where an opening paren for an if statement control block was the last character on a line, or a closing paren was the first. For example: (where lineWidth: 40)
The above case was getting formatted with an extra space at the end of the if statement line and an extra space at the start of the close paren line.