From 3317b966a68bc7bc41f7879e0421a3ff701e403f Mon Sep 17 00:00:00 2001 From: Jordan MacDonald Date: Tue, 14 May 2024 18:26:00 -0400 Subject: [PATCH] Retain trailing newline during justification (#284) --- src/util/reflow.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/util/reflow.rs b/src/util/reflow.rs index 52648e33..154699e6 100644 --- a/src/util/reflow.rs +++ b/src/util/reflow.rs @@ -94,6 +94,9 @@ impl<'a> Reflow<'a> { } } + // Append trailing newline that is stripped during justification + justified.push('\n'); + justified } } @@ -125,7 +128,7 @@ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a buf.data(), "\ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a" +a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\n" ); } @@ -155,7 +158,7 @@ it wasn't obvious.\n", "\ these are words to be used as demos for the thing that this is. this is text reflowing and justification over a few lines. this is just filler text in case -it wasn't obvious." +it wasn't obvious.\n" ); } @@ -204,7 +207,7 @@ of sanity and coherence here! Fun fact of the day number three is that I spent three hours getting this to not branch. There is no way that that micro-optimization will actually save three -hours worth of time, but I did it anyway for no good reason!" +hours worth of time, but I did it anyway for no good reason!\n" ); } @@ -230,7 +233,7 @@ hours worth of time, but I did it anyway for no good reason!" buf.data(), "\ # a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -# a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a" +# a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\n" ); } @@ -262,7 +265,7 @@ languages.\n", "\ // filler text meant to do stuff and things that end up with text nicely // wrappped around a comment delimiter such as the double slashes in c-style -// languages.", +// languages.\n", ); } }