-
Notifications
You must be signed in to change notification settings - Fork 59
[Enhancement] Only Send Updates When Formatting Changed #1188
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
base: develop
Are you sure you want to change the base?
Conversation
...ugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatFormattingService.java
Outdated
Show resolved
Hide resolved
ae2a2c2
to
8f96dc6
Compare
// The Javadoc of onTextReady API says that you should set it to null when the | ||
// document is unchanged. But an even better version is to simply not attempt | ||
// to format a document that is already formatted | ||
if (replacements.isEmpty()) { |
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.
Damn so it would turn out that even when the file is fully formatted it still produces a replacement which looks like:
A full file replacement with the same content... Seems like a bug in the formatter service.
CC @crogoz @carterkozak :(
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.
To avoid having to remote debug your intellij, here is a failing test that exemplifies the issue: https://github.com/palantir/palantir-java-format/pull/1188/files#diff-a6622bd2788dface780176f19bbaecce6308bb0a826e6e6721b0c713bc0e2c68R450
27dfe25
to
70d44a5
Compare
70d44a5
to
b2fb695
Compare
Before this PR
Every format action caused the current buffer to be marked as modified.
After this PR
This was due to us updating the text on every format even if it was unchanged. Now it only updates when something was formatted.
Way more context than you could ever want: https://youtrack.jetbrains.com/issue/IJPL-162382