Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ public void run() {
}

try {
String formattedText = applyReplacements(
request.getDocumentText(),
formatterService.get().getFormatReplacements(request.getDocumentText(), toRanges(request)));
request.onTextReady(formattedText);
List<Replacement> replacements =
formatterService.get().getFormatReplacements(request.getDocumentText(), toRanges(request));

// 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()) {
Copy link
Member Author

@bmarcaur bmarcaur Mar 6, 2025

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:

image

A full file replacement with the same content... Seems like a bug in the formatter service.

CC @crogoz @carterkozak :(

Copy link
Member Author

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

return;
}

request.onTextReady(applyReplacements(request.getDocumentText(), replacements));
} catch (FormatterException e) {
request.onError(
Notifications.PARSING_ERROR_TITLE,
Expand Down