Skip to content
Permalink
Browse files
Preserve paragraph breaks when word wrapping
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Feb 28, 2020
1 parent 1f14c17 commit ca1bbe517eded1a89491863af6ccacc042cfb77a
Showing 2 changed files with 6 additions and 1 deletion.
@@ -92,7 +92,7 @@ public static String wrapBody(String body, int lineLength) {
var nextLine = lines.peekFirst();
if (nextLine != null) {
var nextIndent = indentation(nextLine);
if (!indentation.equals(filterIndent(nextIndent))) {
if (nextLine.isBlank() || !indentation.equals(filterIndent(nextIndent))) {
lines.addFirst(filterIndent(indentation) + split.getValue());
} else {
lines.removeFirst();
@@ -57,4 +57,9 @@ void complex() {
"Ok, I will fix that in a new commit!",
10));
}

@Test
void emptyLines() {
assertEquals("hello\nthere\n\nyou", WordWrap.wrapBody("hello there\n\nyou", 3));
}
}

0 comments on commit ca1bbe5

Please sign in to comment.