mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-25 00:21:46 +00:00
terminal: reset wrap state for CSI 2 K (#13637)
#13616 Reset the soft-wrap state when CSI 2 K erases the complete cursor row. Previously, erase-to-end reset the flag while complete-line erase left it set. WezTerm, kitty, Alacritty, VTE, and xterm.js clear the wrap state for complete-line erase. xterm preserves it, but xterm copies physical rows during resize instead of reflowing them. Diverge from xterm so reflow in Ghostty does not treat erased rows as one logical line, and cover the behavior with a resize regression test.
This commit is contained in:
@@ -3267,9 +3267,14 @@ pub fn eraseLine(
|
||||
break :left .{ 0, x + 1 };
|
||||
},
|
||||
|
||||
// Note that it seems like complete should reset the soft-wrap
|
||||
// state of the line but in xterm it does not.
|
||||
.complete => .{ 0, self.cols },
|
||||
.complete => complete: {
|
||||
// Xterm preserves this flag for EL2, but it also doesn't reflow
|
||||
// rows when resizing. Since we do, the erased row must no longer
|
||||
// continue onto the next row.
|
||||
self.screens.active.cursorResetWrap();
|
||||
|
||||
break :complete .{ 0, self.cols };
|
||||
},
|
||||
|
||||
else => {
|
||||
log.err("unimplemented erase line mode: {}", .{mode});
|
||||
@@ -13596,6 +13601,35 @@ test "Terminal: eraseLine complete preserves background sgr" {
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: eraseLine complete resets wrap" {
|
||||
const alloc = testing.allocator;
|
||||
const io_impl = testing.io;
|
||||
var t = try init(io_impl, alloc, .{ .rows = 5, .cols = 5 });
|
||||
defer t.deinit(alloc);
|
||||
|
||||
for ("ABCDE123") |c| try t.print(c);
|
||||
{
|
||||
const list_cell = t.screens.active.pages.getCell(.{ .active = .{ .x = 0, .y = 0 } }).?;
|
||||
try testing.expect(list_cell.row.wrap);
|
||||
}
|
||||
|
||||
t.setCursorPos(1, 1);
|
||||
t.eraseLine(.complete, false);
|
||||
|
||||
{
|
||||
const list_cell = t.screens.active.pages.getCell(.{ .active = .{ .x = 0, .y = 0 } }).?;
|
||||
try testing.expect(!list_cell.row.wrap);
|
||||
}
|
||||
try t.print('X');
|
||||
try t.resize(alloc, .{ .rows = 5, .cols = 10 });
|
||||
|
||||
{
|
||||
const str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("X\n123", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: eraseLine complete protected attributes respected with iso" {
|
||||
const alloc = testing.allocator;
|
||||
const io_impl = testing.io;
|
||||
|
||||
Reference in New Issue
Block a user