Skip to content

Commit 5e0d9e3

Browse files
dweissgoogle-java-format Team
authored andcommitted
Fix different formatting of block line comments with openjdk 23+
Fixes #1153. Fixes #1161 COPYBARA_INTEGRATE_REVIEW=#1161 from dweiss:1153-block-line-comments-in-java23 e3ed83c PiperOrigin-RevId: 674304999
1 parent 8a0e3b3 commit 5e0d9e3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public String rewrite(Tok tok, int maxWidth, int column0) {
4949
List<String> lines = new ArrayList<>();
5050
Iterator<String> it = Newlines.lineIterator(text);
5151
while (it.hasNext()) {
52-
lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
52+
if (tok.isSlashSlashComment()) {
53+
lines.add(CharMatcher.whitespace().trimFrom(it.next()));
54+
} else {
55+
lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
56+
}
5357
}
5458
if (tok.isSlashSlashComment()) {
5559
return indentLineComments(lines, column0);

0 commit comments

Comments
 (0)