From 1f3138add704fd7353147b5b239fd345de9fd128 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 25 Sep 2023 16:23:29 -0700 Subject: [PATCH] terminal: eraseChars resets wrap --- src/terminal/Terminal.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index a2d620840..b9077544b 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -1333,6 +1333,9 @@ pub fn eraseChars(self: *Terminal, count: usize) void { const tracy = trace(@src()); defer tracy.end(); + // This resets the pending wrap state + self.screen.cursor.pending_wrap = false; + // Our last index is at most the end of the number of chars we have // in the current line. const end = @min(self.cols, self.screen.cursor.x + count); @@ -2999,6 +3002,24 @@ test "Terminal: deleteChars resets wrap" { } } +test "Terminal: eraseChars resets wrap" { + const alloc = testing.allocator; + var t = try init(alloc, 5, 5); + defer t.deinit(alloc); + + for ("ABCDE") |c| try t.print(c); + try testing.expect(t.screen.cursor.pending_wrap); + t.eraseChars(1); + try testing.expect(!t.screen.cursor.pending_wrap); + try t.print('X'); + + { + var str = try t.plainString(testing.allocator); + defer testing.allocator.free(str); + try testing.expectEqualStrings("ABCDX", str); + } +} + test "Terminal: setCursorColAbsolute resets pending wrap" { const alloc = testing.allocator; var t = try init(alloc, 5, 5);