terminal: deleteChars resets pending wrap state

This commit is contained in:
Mitchell Hashimoto
2023-09-25 16:21:04 -07:00
parent 27cc8e5529
commit 804d252787

View File

@ -1309,6 +1309,9 @@ pub fn deleteChars(self: *Terminal, count: usize) !void {
if (count == 0) return;
// This resets the pending wrap state
self.screen.cursor.pending_wrap = false;
// We go from our cursor right to the end and either copy the cell
// "count" away or clear it.
const line = self.screen.getRow(.{ .active = self.screen.cursor.y });
@ -2978,6 +2981,24 @@ test "Terminal: deleteChars should shift left" {
}
}
test "Terminal: deleteChars 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);
try t.deleteChars(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);