From a58b03c5a0c6307b9a9d10f463c0e413c4ef1393 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 25 Mar 2024 10:06:14 -0700 Subject: [PATCH] terminal: insertLines clears row wrap state --- src/terminal/Terminal.zig | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index faac7ec02..9079b2c89 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -1337,6 +1337,9 @@ pub fn insertLines(self: *Terminal, count: usize) void { unreachable; }; + // Row never is wrapped + dst.wrap = false; + continue; } @@ -1346,6 +1349,10 @@ pub fn insertLines(self: *Terminal, count: usize) void { dst.* = src.*; src.* = dst_row; + // Row never is wrapped + dst.wrap = false; + src.wrap = false; + // Ensure what we did didn't corrupt the page p.page.data.assertIntegrity(); continue; @@ -1362,6 +1369,9 @@ pub fn insertLines(self: *Terminal, count: usize) void { self.scrolling_region.left, (self.scrolling_region.right - self.scrolling_region.left) + 1, ); + + // Row never is wrapped + dst.wrap = false; } // The operations above can prune our cursor style so we need to @@ -4237,7 +4247,7 @@ test "Terminal: insertLines more than remaining" { } } -test "Terminal: insertLines resets wrap" { +test "Terminal: insertLines resets pending wrap" { const alloc = testing.allocator; var t = try init(alloc, .{ .rows = 5, .cols = 5 }); defer t.deinit(alloc); @@ -4255,6 +4265,32 @@ test "Terminal: insertLines resets wrap" { } } +test "Terminal: insertLines resets wrap" { + const alloc = testing.allocator; + var t = try init(alloc, .{ .rows = 3, .cols = 3 }); + defer t.deinit(alloc); + + try t.print('1'); + t.carriageReturn(); + try t.linefeed(); + for ("ABCDEF") |c| try t.print(c); + t.setCursorPos(1, 1); + t.insertLines(1); + try t.print('X'); + + { + const str = try t.plainString(testing.allocator); + defer testing.allocator.free(str); + try testing.expectEqualStrings("X\n1\nABC", str); + } + + { + const list_cell = t.screen.pages.getCell(.{ .active = .{ .x = 0, .y = 2 } }).?; + const row = list_cell.row; + try testing.expect(!row.wrap); + } +} + test "Terminal: insertLines multi-codepoint graphemes" { const alloc = testing.allocator; var t = try init(alloc, .{ .rows = 5, .cols = 5 });