Expand terminal input E2E coverage

This commit is contained in:
slhx agent
2026-06-21 18:26:02 +02:00
parent 9aafe0e01c
commit 0d4d0ec425
4 changed files with 153 additions and 62 deletions
+9 -6
View File
@@ -343,10 +343,14 @@ fn readEditorInputFdAlloc(allocator: std.mem.Allocator, fd: std.posix.fd_t) !?[]
if (second_n == 0) return try bytes.toOwnedSlice(allocator);
try bytes.append(allocator, one[0]);
if (one[0] == '[') {
const third_ready = std.posix.poll(&fds, 30) catch 0;
if (third_ready == 0 or (fds[0].revents & std.posix.POLL.IN) == 0) return try bytes.toOwnedSlice(allocator);
const third_n = try std.posix.read(fd, &one);
if (third_n != 0) try bytes.append(allocator, one[0]);
while (bytes.items.len < 8) {
const next_ready = std.posix.poll(&fds, 30) catch 0;
if (next_ready == 0 or (fds[0].revents & std.posix.POLL.IN) == 0) break;
const next_n = try std.posix.read(fd, &one);
if (next_n == 0) break;
try bytes.append(allocator, one[0]);
if (one[0] >= '@' and one[0] <= '~') break;
}
}
return try bytes.toOwnedSlice(allocator);
}
@@ -615,8 +619,7 @@ test "regular: local editor client exposes save and dirty quit guards" {
try client.handleInput("i");
try client.handleInput("!");
try client.handleInput(" ");
try client.handleInput("n");
try client.handleTraceLine("key escape");
try client.handleInput(" ");
try client.handleInput("q");
try std.testing.expect(client.requestedQuit());