-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(fmt): account for CRLF when handling cursor #11874
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
Conversation
// Figure out if the cursor needs to check for CR (`\r`). | ||
if let Some(item) = source_unit.items.first() { | ||
self.check_crlf(item.span.to(source_unit.items.last().unwrap().span)); | ||
} |
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 believe that initially checking if the file contains \r
to then skip checking the sourcemap each time is more efficient, but feel free to push back if u disagree
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.
this is fine, it assumes cr = crlf but thats ok because bare cr is usually invalid code although might not be rejected by solc
please fix the "closes" directive in the PR description to actually auto close the issue
Motivation
closes:
Solution
rather than blindly advancing the cursor by 1, we need to check if the current character is
\r
to account for the whole CRLF sequence and advance 2 chars instead.PR Checklist