Do not scan nodes preceding formatted region, just skip over them#9420
Merged
Conversation
| @@ -33,6 +33,7 @@ namespace ts { | |||
| scan(): SyntaxKind; | |||
| // Sets the text for the scanner to scan. An optional subrange starting point and length | |||
Member
There was a problem hiding this comment.
move new line above old comment
Member
|
I don't know enough about the scanner, especially formattingScanner, to know if those changes are right, but otherwise it looks good, with some comments. |
Contributor
|
@vladima can you take a look. |
| } | ||
|
|
||
| function skipToEndOf(node: Node): void { | ||
| scanner.setTextPos(backUpWhitespace()); |
Contributor
There was a problem hiding this comment.
usually node.end points to something that is not whitespace. Can you please give an example of a case when end of node points to a whitespace so we need to step back to the first non-whitespace position?
Author
There was a problem hiding this comment.
I tested and it works without backUpWhitespace. Now I'm wondering why I thought it was needed.
Contributor
|
👍 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #7686
Also took the time to clear up some confusion about
isWhiteSpaceandisLineBreak: they are disjoint, but in many places people appear to have assumed thatisWhiteSpaceimpliesisLineBreak. MaybeisWhiteSpaceshould be renamed toisNonLineBreakWhiteSpace?