Skip to content

Commit

Permalink
Fix an off-by-one bug with column limit handling for text blocks
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695348215
  • Loading branch information
cushon authored and google-java-format Team committed Nov 11, 2024
1 parent 81e9e1c commit d4b3f0d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ private void indentTextBlocks(
initialLines.get(1).stripTrailing().length() - lines.get(0).stripTrailing().length();

String prefix =
(deindent == 0 || lines.stream().anyMatch(x -> x.length() + startColumn > columnLimit))
(deindent == 0
|| lines.stream().anyMatch(x -> x.length() + startColumn - 1 > columnLimit))
? ""
: " ".repeat(startColumn - 1);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class T {
String a =
"""
# No implicit input file, because they can only be created outside a symbolic macro,
""";

String b =
"""
# No implicit input file, because they can only be created outside a symbolic macro,
""";
String c =
"""
# No implicit input file, because they can only be created outside a symbolic macro,
""";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class T {
String a =
"""
# No implicit input file, because they can only be created outside a symbolic macro,
""";

String b =
"""
# No implicit input file, because they can only be created outside a symbolic macro,
""";
String c =
"""
# No implicit input file, because they can only be created outside a symbolic macro,
""";
}

0 comments on commit d4b3f0d

Please sign in to comment.