From 74f0e38b57083f3ae2329017c322892e7a8e41e5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 1 Mar 2023 17:42:46 -0800 Subject: [PATCH] screen: only trim if we're not wrapping on col growing --- src/terminal/Screen.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index ff24c15cf..564439e45 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -1922,10 +1922,14 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void { var x: usize = old.cols; wrapping: while (iter.next()) |wrapped_row| { // Trim the row from the right so that we ignore all trailing - // empty chars and don't wrap them. + // empty chars and don't wrap them. We only do this if the + // row is NOT wrapped again because the whitespace would be + // meaningful. const wrapped_cells = trim: { var i: usize = old.cols; - while (i > 0) : (i -= 1) if (!wrapped_row.getCell(i - 1).empty()) break; + if (!wrapped_row.header().flags.wrap) { + while (i > 0) : (i -= 1) if (!wrapped_row.getCell(i - 1).empty()) break; + } break :trim wrapped_row.storage[1 .. i + 1]; };