terminal: eraseChars resets wrap

This commit is contained in:
Mitchell Hashimoto
2023-09-25 16:23:29 -07:00
parent 804d252787
commit 1f3138add7

View File

@ -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);