Skip to content

Commit

Permalink
Fix different formatting of block line comments with openjdk 23+
Browse files Browse the repository at this point in the history
Fixes #1153.

Fixes #1161

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1161 from dweiss:1153-block-line-comments-in-java23 e3ed83c
PiperOrigin-RevId: 674301748
  • Loading branch information
dweiss authored and google-java-format Team committed Sep 13, 2024
1 parent 8a0e3b3 commit cb2cc0c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public String rewrite(Tok tok, int maxWidth, int column0) {
List<String> lines = new ArrayList<>();
Iterator<String> it = Newlines.lineIterator(text);
while (it.hasNext()) {
lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
if (tok.isSlashSlashComment()) {
lines.add(CharMatcher.whitespace().trimFrom(it.next()));
} else {
lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
}
}
if (tok.isSlashSlashComment()) {
return indentLineComments(lines, column0);
Expand Down

0 comments on commit cb2cc0c

Please sign in to comment.