From eeba3057f9238711d6db7e238ed808bf0ab1af87 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 18 Sep 2023 22:14:04 -0700 Subject: [PATCH] terminal: CSI G must reset pending wrap state Fixes #479 --- src/terminal/Terminal.zig | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index ba53ffbfe..cdcda7fc5 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -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.