-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Formatting implementation using new tree #1109
Conversation
…n for end line position
* { var x; | ||
* } | ||
* Normally indentation is applied only to the first token in line so at glance 'var' should not be touched. | ||
* However if some format rule removes new line between ')' and '{' 'var' will become |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't quite get this comment. "if some format rule removes new line between ')' and '{'" then we'll have:
while (true) { var x;
}
And 'var' will not be the first token in line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. was thinking about another example with writing this comment, will make it more clear
return find(sourceFile); | ||
|
||
function find(n: Node): Node { | ||
var candidate = forEachChild(n, c => startEndContainsRange(c.getStart(sourceFile), c.end, range) && c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might actually be able to make this faster if you fed in the optional cbNodes
argument to perform a binary search.
Formatting implementation using new tree
This PR adds implementation of code formatting that works atop of new tree. I would not suggest to review the code commit-by-commit as intermediate checkins here often contain non-relevant details that are ultimately removed in final implementation.