terminal: CSI G must reset pending wrap state

Fixes #479
This commit is contained in:
Mitchell Hashimoto
2023-09-18 22:14:04 -07:00
parent 063a66ea6c
commit eeba3057f9

View File

@ -1008,10 +1008,14 @@ pub fn setCursorColAbsolute(self: *Terminal, col_req: usize) void {
return;
}
if (self.status_display != .main) return; // TODO
if (self.status_display != .main) {
log.err("setCursorColAbsolute: not implemented on status display", .{});
return; // TODO
}
const col = if (col_req == 0) 1 else col_req;
self.screen.cursor.x = @min(self.cols, col) - 1;
self.screen.cursor.pending_wrap = false;
}
/// Erase the display.
@ -2743,6 +2747,18 @@ test "Terminal: deleteChars should shift left" {
}
}
test "Terminal: setCursorColAbsolute resets pending 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.setCursorColAbsolute(1);
try testing.expect(!t.screen.cursor.pending_wrap);
try testing.expectEqual(@as(usize, 0), t.screen.cursor.x);
}
// https://github.com/mitchellh/ghostty/issues/272
// This is also tested in depth in screen resize tests but I want to keep
// this test around to ensure we don't regress at multiple layers.