mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 11:16:08 +03:00
terminal: CUB with reverse wrap on first row should not crash
This commit is contained in:
@ -1464,12 +1464,6 @@ pub fn cursorLeft(self: *Terminal, count_req: usize) void {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If our previous line is not wrapped then we are done.
|
||||
if (wrap_mode != .reverse_extended) {
|
||||
const row = self.screen.getRow(.{ .active = self.screen.cursor.y - 1 });
|
||||
if (!row.isWrapped()) break;
|
||||
}
|
||||
|
||||
// UNDEFINED TERMINAL BEHAVIOR. This situation is not handled in xterm
|
||||
// and currently results in a crash in xterm. Given no other known
|
||||
// terminal [to me] implements XTREVWRAP2, I decided to just mimick
|
||||
@ -1482,6 +1476,12 @@ pub fn cursorLeft(self: *Terminal, count_req: usize) void {
|
||||
break;
|
||||
}
|
||||
|
||||
// If our previous line is not wrapped then we are done.
|
||||
if (wrap_mode != .reverse_extended) {
|
||||
const row = self.screen.getRow(.{ .active = self.screen.cursor.y - 1 });
|
||||
if (!row.isWrapped()) break;
|
||||
}
|
||||
|
||||
self.screen.cursor.y -= 1;
|
||||
self.screen.cursor.x = right_margin;
|
||||
count -= 1;
|
||||
@ -6154,6 +6154,22 @@ test "Terminal: cursorLeft extended reverse wrap above top scroll region" {
|
||||
try testing.expectEqual(@as(usize, 0), t.screen.cursor.y);
|
||||
}
|
||||
|
||||
test "Terminal: cursorLeft reverse wrap on first row" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 5, 5);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
t.modes.set(.wraparound, true);
|
||||
t.modes.set(.reverse_wrap, true);
|
||||
|
||||
t.setTopAndBottomMargin(3, 0);
|
||||
t.setCursorPos(1, 2);
|
||||
t.cursorLeft(1000);
|
||||
|
||||
try testing.expectEqual(@as(usize, 0), t.screen.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 0), t.screen.cursor.y);
|
||||
}
|
||||
|
||||
test "Terminal: cursorDown basic" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 5, 5);
|
||||
|
Reference in New Issue
Block a user