summaryrefslogtreecommitdiff
path: root/src/ninep/pty.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/pty.zig')
-rw-r--r--src/ninep/pty.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig
index d80f7175..e68ad84f 100644
--- a/src/ninep/pty.zig
+++ b/src/ninep/pty.zig
@@ -378,9 +378,11 @@ pub fn noteMarks(p: *Pardes, id: usize, pane: *Pane) void {
/// Answers a run whose command ended with `status`: the header and the
/// output it printed.
fn finish(p: *Pardes, slot: *Run, pane: *Pane, status_code: ?i32) void {
- const printed = pardes.panes.terminal.commandOutput(pane, p.gpa, output_rows) catch
+ // As the authority's emulator has it (taped): a screen-state replica's
+ // is its deltas', which a lagging client's can be states behind, its
+ // pins in pages it never had (ghostty's leftWrap overflowed on one).
+ const printed = pardes.tape.value(.prompt, printedBy, .{ pane, p.scratch.allocator() }) orelse
return answer(p, slot, "error out of memory", .{});
- defer p.gpa.free(printed.text);
// Keep the tail, cut at a line start so the first line kept is whole.
var keep: []const u8 = printed.text;
if (keep.len > output_cap) {
@@ -409,6 +411,14 @@ fn finish(p: *Pardes, slot: *Run, pane: *Pane, status_code: ?i32) void {
answer(p, slot, "exit {s}", .{status});
}
+const Printed = struct { text: []const u8, whole: bool };
+
+/// What pane `pane`'s command printed (terminal.commandOutput), in `arena`.
+fn printedBy(pane: *Pane, arena: std.mem.Allocator) ?Printed {
+ const out = pardes.panes.terminal.commandOutput(pane, arena, output_rows) catch return null;
+ return .{ .text = out.text, .whole = out.whole };
+}
+
/// The shell itself exited (a run's `exit 3`, or one typed): a run waiting
/// on the command it ran answers with the shell's status and what it
/// printed, and the log says `exit` before the pane's `del`. Unknown, the