diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ninep/pty.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index 5c9a6289..5a974adf 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -324,6 +324,9 @@ pub fn noteMarks(p: *Pardes, id: usize, pane: *Pane) void { p.emitWrite(id, slot.line); p.emitWrite(id, "\r"); pardes.panes.terminal.noteCommand(pane, slot.line); + // The run is the shell's first command: a greeting `ls` typed at the + // same prompt would run after it, and its C would be taken for ours. + pane.greet = false; slot.phase = .sent; return; } @@ -768,6 +771,27 @@ test "pty/data writes at the shell and reads the raw stream" { try testing.expectEqualStrings("still", rd(p, data, 0, 64).bytes); } +test "a run waiting for a new terminal's first prompt is the only line typed there, no greeting after it" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + p.panes[0].?.greet = true; // a Term's, in a window (resized) + p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); + while (p.nextEffect()) |_| {} + const node = Node.of(serialOf(p), .pty_run); + const h = call(p, .{ .tag = 1, .op = .open, .node = node }).reply.handle; + _ = call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h, .data = "true\n" }); + p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } }); + var sent: [32]u8 = undefined; + var len: usize = 0; + while (p.nextEffect()) |e| if (e == .write) { + const b = e.write.bytes.slice(); + @memcpy(sent[len..][0..b.len], b); + len += b.len; + }; + try testing.expectEqualStrings("true\r", sent[0..len]); +} + test "run answers how its command ended once the shell is back at a prompt" { const gpa = testing.allocator; const p = try withTerm(gpa); |
