terminal: erase line right should reset soft wrap state

This commit is contained in:
Mitchell Hashimoto
2024-01-19 14:08:09 -08:00
parent e7169afffa
commit bab932431f
2 changed files with 36 additions and 2 deletions

View File

@ -1370,6 +1370,9 @@ pub fn eraseLine(
if (cell.attrs.wide_spacer_tail) x -= 1;
}
// This resets the soft-wrap of this line
row.setWrapped(false);
break :right .{ x, row.lenCells() };
},
@ -1387,6 +1390,8 @@ 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, row.lenCells() },
else => {
@ -5193,7 +5198,7 @@ test "Terminal: eraseLine simple erase right" {
}
}
test "Terminal: eraseLine resets wrap" {
test "Terminal: eraseLine resets pending wrap" {
const alloc = testing.allocator;
var t = try init(alloc, 5, 5);
defer t.deinit(alloc);
@ -5211,6 +5216,33 @@ test "Terminal: eraseLine resets wrap" {
}
}
test "Terminal: eraseLine resets wrap" {
const alloc = testing.allocator;
var t = try init(alloc, 5, 5);
defer t.deinit(alloc);
for ("ABCDE123") |c| try t.print(c);
{
const row = t.screen.getRow(.{ .active = 0 });
try testing.expect(row.isWrapped());
}
t.setCursorPos(1, 1);
t.eraseLine(.right, false);
{
const row = t.screen.getRow(.{ .active = 0 });
try testing.expect(!row.isWrapped());
}
try t.print('X');
{
const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str);
try testing.expectEqualStrings("X\n123", str);
}
}
test "Terminal: eraseLine right preserves background sgr" {
const alloc = testing.allocator;
var t = try init(alloc, 5, 5);

View File

@ -27,7 +27,9 @@ first or second cell of the two-cell character, both cells should be erased.
If `n` is `0`, perform an **erase line right** operation. Erase line right
is equivalent to [Erase Character (ECH)](/vt/ech) with `n` set to the total
remaining columns from the cursor to the end of the line (and including
the cursor).
the cursor). If the line is softwrapped, only the single row is erased;
it does not erase through the wrap. Further, the wrap state of the row is
reset such that the line is no longer considered wrapped.
If `n` is `1`, perform an **erase line left** operation. This replaces
the `n` cells left of and including the cursor with a blank character and