Skip to content

Do not scan nodes preceding formatted region, just skip over them#9420

Merged
mhegazy merged 4 commits into
masterfrom
formatting_loc
Jul 5, 2016
Merged

Do not scan nodes preceding formatted region, just skip over them#9420
mhegazy merged 4 commits into
masterfrom
formatting_loc

Conversation

@ghost

@ghost ghost commented Jun 29, 2016

Copy link
Copy Markdown

Fixes #7686
Also took the time to clear up some confusion about isWhiteSpace and isLineBreak: they are disjoint, but in many places people appear to have assumed that isWhiteSpace implies isLineBreak. Maybe isWhiteSpace should be renamed to isNonLineBreakWhiteSpace?

@ghost ghost assigned vladima Jun 29, 2016
@ghost ghost force-pushed the formatting_loc branch from f5f2448 to 5ab0f3c Compare June 29, 2016 15:37
@ghost ghost force-pushed the formatting_loc branch from 5ab0f3c to 0a61334 Compare June 29, 2016 15:39
@ghost ghost assigned sandersn Jun 29, 2016
Comment thread src/compiler/scanner.ts
@@ -33,6 +33,7 @@ namespace ts {
scan(): SyntaxKind;
// Sets the text for the scanner to scan. An optional subrange starting point and length

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

move new line above old comment

@sandersn

Copy link
Copy Markdown
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.

@mhegazy

mhegazy commented Jun 29, 2016

Copy link
Copy Markdown
Contributor

@vladima can you take a look.

}

function skipToEndOf(node: Node): void {
scanner.setTextPos(backUpWhitespace());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tested and it works without backUpWhitespace. Now I'm wondering why I thought it was needed.

@vladima

vladima commented Jul 5, 2016

Copy link
Copy Markdown
Contributor

👍

@mhegazy mhegazy merged commit 1102fa6 into master Jul 5, 2016
@mhegazy mhegazy deleted the formatting_loc branch July 5, 2016 21:40
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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.

4 participants