8afffece
test: pin that a selection paints its cells plain, whatever style they carry
a73x 2026-09-04 18:04
Commit message
src/tui/paint.zig
| Old | New | ||
|---|---|---|---|
| @@ -439,6 +439,25 @@ test "rowToVt: an SGR per style change, a wide glyph once, a trailing-blank stop | |||
| 439 | ); | 439 | ); |
| 440 | } | 440 | } |
| 441 | 441 | ||
| 442 | test "rowToVt: a selection paints its cells PLAIN, whatever style they carry" { | ||
| 443 | // An inversion over a bold red cell that kept its own pen is a selection | ||
| 444 | // the user cannot read: the terminal renders inverse-on-red, not the | ||
| 445 | // highlight. The span opens with a full reset and emits no SGR of its | ||
| 446 | // own, so a styled row under a selection comes out uniformly inverted — | ||
| 447 | // and the head before it keeps its style, which is what says the reset | ||
| 448 | // belongs to the span and not to the row. | ||
| 449 | const alloc = std.testing.allocator; | ||
| 450 | const g = try authoredGrid(alloc, 12, 2, "\x1b[2;1H\x1b[1;31mabcdef"); | ||
| 451 | defer g.deinit(); | ||
| 452 | |||
| 453 | const row = try rowToVt(alloc, g, 1, .{ .col_off = 0, .cols = 80 }, .{ .from = 3, .to = 11 }); | ||
| 454 | defer alloc.free(row); | ||
| 455 | try std.testing.expectEqualStrings( | ||
| 456 | "\x1b[0m\x1b[0;1;31mabc\x1b[4G\x1b[0m\x1b[7mdef \x1b[0m", | ||
| 457 | row, | ||
| 458 | ); | ||
| 459 | } | ||
| 460 | |||
| 442 | test "renderClipped inverts the highlighted rows and leaves the rest alone" { | 461 | test "renderClipped inverts the highlighted rows and leaves the rest alone" { |
| 443 | const alloc = std.testing.allocator; | 462 | const alloc = std.testing.allocator; |
| 444 | const g = try authoredGrid(alloc, 12, 4, "row-zero\r\nrow-one\r\nrow-two\r\nrow-three"); | 463 | const g = try authoredGrid(alloc, 12, 4, "row-zero\r\nrow-one\r\nrow-two\r\nrow-three"); |