Add terminal E2E matrix runner

This commit is contained in:
slhx agent
2026-06-21 17:36:24 +02:00
parent 86af6d774e
commit 5d7f239d34
3 changed files with 216 additions and 80 deletions
+42 -16
View File
@@ -2373,26 +2373,36 @@ fn appendEditorCells(
is_cursor_line: bool,
cursor_col: usize,
) !void {
_ = cursor_col;
var remaining = max_cells;
if (is_cursor_line and remaining > 0) {
var i: usize = 0;
var source_col: usize = 0;
var visual_col: usize = 0;
var drew_cursor = false;
while (i < bytes.len and visual_col < max_cells) {
if (is_cursor_line and !drew_cursor and source_col >= cursor_col) {
try out.appendSlice(allocator, ansi_cursor);
try out.appendSlice(allocator, "");
try out.appendSlice(allocator, ansi_reset);
try out.appendSlice(allocator, ansi_current_line);
try out.appendSlice(allocator, ansi_text);
visual_col += 1;
drew_cursor = true;
if (visual_col >= max_cells) break;
}
const len = std.unicode.utf8ByteSequenceLength(bytes[i]) catch 1;
const end = @min(bytes.len, i + len);
const width = @max(@as(usize, 1), session_mod.cellWidth(bytes[i..end]));
if (visual_col + width > max_cells) break;
try out.appendSlice(allocator, bytes[i..end]);
source_col += width;
visual_col += width;
i = end;
}
if (is_cursor_line and !drew_cursor and visual_col < max_cells) {
try out.appendSlice(allocator, ansi_cursor);
try out.appendSlice(allocator, "");
try out.appendSlice(allocator, ansi_reset);
try out.appendSlice(allocator, ansi_current_line);
try out.appendSlice(allocator, ansi_text);
remaining -= 1;
}
var i: usize = 0;
var col: usize = 0;
while (i < bytes.len and col < remaining) {
const len = std.unicode.utf8ByteSequenceLength(bytes[i]) catch 1;
const end = @min(bytes.len, i + len);
const width = @max(@as(usize, 1), session_mod.cellWidth(bytes[i..end]));
if (col + width > remaining) break;
try out.appendSlice(allocator, bytes[i..end]);
col += width;
i = end;
}
}
@@ -2560,7 +2570,8 @@ test "regular: scripted narrow terminal trace edits saves exits and replays save
const result = try runTrace(std.testing.allocator, .{ .width = 12, .height = 4 }, trace);
defer result.deinit(std.testing.allocator);
try std.testing.expect(result.quit);
try std.testing.expect(std.mem.indexOf(u8, result.frame, "bc") != null);
try std.testing.expect(std.mem.indexOf(u8, result.frame, "") != null);
try std.testing.expect(std.mem.indexOf(u8, result.frame, "bc") != null);
try assertLinesFit(result.frame, 12);
try std.testing.expectEqualStrings("aébc", result.saved_bytes.?);
@@ -4901,3 +4912,18 @@ test "regular: normal mode Space leader still works after insert escape" {
try client.handleInput("w");
try std.testing.expectEqualStrings("abc", try client.saved());
}
test "regular: cursor marker follows cursor column after typed text" {
var client = try Client.init(std.testing.allocator, .{ .width = 48, .height = 6 });
defer client.deinit();
try client.handleTraceLine("open ");
client.enterInsertMode();
for ("what") |byte| {
const key_bytes = [_]u8{byte};
try client.handleInput(&key_bytes);
}
const frame = try client.render(std.testing.allocator);
defer std.testing.allocator.free(frame);
try std.testing.expect(std.mem.indexOf(u8, frame, "what") != null);
try std.testing.expect(std.mem.indexOf(u8, frame, "▌what") == null);
}