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
Swap diff for faster-diff #4816
Conversation
I'm not seeing a clear route to making faster-diff's behavior exactly match diff's behavior without gutting it - how exactly does this cursor offsetting need to be? Also, any ideas about whether there's some UTF8 character that would be useful as a cursor standin? |
As exact as possible :) Can you run
Perhaps one of the non-characters? |
After looking through the test failures, it looks like cursor position can differ by parser (according to the current behavior in |
This fell off the radar for a moment, but I figured out how to update the tests properly - and rebased on master. |
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.
Changes to the output appear reasonable.
Anything else to fix up so that this is mergable? |
Looks like you’ve got conflicts :/ |
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.
We've had very little usage of the cursor preservation code so it's not surprising that it's very slow. The changes are unfortunate but I think it's not the end of the world since they only seem to appear when optional punctuation is being injected, so it's not the end of the world (would be nice if it got fixed though).
Thanks for doing this!
@@ -208,7 +207,7 @@ thisWontBeFormatted ( 1 ,3) | |||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |||
thisWontBeFormatted ( 1 ,3) | |||
|
|||
thisWillBeFormatted(2, 3<|>); | |||
thisWillBeFormatted(2, <|>3); |
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.
None of those changes seem right.
thisWillBeFormatted (2 ,3, <|> )
If your cursor was after the 3, you don't want it to jump before the 3.
const y = 5; | ||
<|> | ||
const y = 5<|>; | ||
|
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.
The cursor was on the line after the 5, you don't want it to become in the same line as the 5
Is the idea that most editor extensions do their own cursor logic instead of using Prettier's functionality? It looks like the VSCode extension does its own thing, whereas the Atom one uses formatWithCursor. |
I have no idea. I know I use |
Closing in favor of #6164, though it's unclear whether that one'll ever land. |
Refs #4801
The faster-diff module appears to be seriously modeled after the O(ND) difference paper, whereas I'm not sure about the diff implementation. This switches prettier to faster-diff. faster-diff is much faster - around 20x speedup.
But: