diff --git a/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java b/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java index 81ea800da..ab4093a11 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java +++ b/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java @@ -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); diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/B361077825.input b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B361077825.input new file mode 100644 index 000000000..c93942a5d --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B361077825.input @@ -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, + """; +} diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/B361077825.output b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B361077825.output new file mode 100644 index 000000000..b407bfe26 --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/B361077825.output @@ -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, +"""; +}