summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index c2bde804..ea03b3eb 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -1638,6 +1638,24 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe
_ = exec.executeFrom(p, 0, "a = 1\r\nb = \x1b[201~2", true);
Sent.drain(p);
try std.testing.expectEqualStrings("a = 1\rb = [201~2\r", Sent.said(1));
+ // Into a REPL that takes a bracketed paste (3.13's), the Enter waits
+ // for the REPL to answer the paste: read with it, it would be part of it.
+ p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?2004h" } });
+ Sent.drain(p);
+ _ = exec.executeFrom(p, 0, "print(1)", true);
+ Sent.drain(p);
+ try std.testing.expectEqualStrings("\x1b[200~print(1)\x1b[201~", Sent.said(1));
+ p.update(.{ .output = .{ .pane = 1, .bytes = "print(1)" } });
+ Sent.drain(p);
+ try std.testing.expectEqualStrings("\r", Sent.said(1));
+ // Nothing answering, it goes when its wait is up.
+ _ = exec.executeFrom(p, 0, "print(2)", true);
+ p.stepped_ns += 300 * std.time.ns_per_ms;
+ p.update(.tick);
+ Sent.drain(p);
+ try std.testing.expect(std.mem.endsWith(u8, Sent.said(1), "\x1b[200~print(2)\x1b[201~\r"));
+ p.update(.{ .output = .{ .pane = 1, .bytes = "\x1b[?2004l" } });
+ Sent.len[1] = 0;
// A block left open by its indented last line gets the blank line that
// ends it: a second Enter.
_ = exec.executeFrom(p, 0, "def f():\n return 1", true);
@@ -5333,7 +5351,10 @@ pub const Pardes = struct {
}
p.clip_pending = null;
},
- .tick => Messages.advanceMessages(p),
+ .tick => {
+ Messages.advanceMessages(p);
+ for (0..p.panes.len) |id| exec.flushReplEnter(p, id, false);
+ },
else => {},
}
if (p.fs.listeners != 0) p.fs.origin = switch (ev) {
@@ -5377,6 +5398,7 @@ pub const Pardes = struct {
ctlfs.events.notePtyOutput(p, o.pane, o.bytes);
panes.Terminal.feedOutput(p, pane, o.bytes);
ctlfs.pty.noteMarks(p, o.pane, pane);
+ exec.flushReplEnter(p, o.pane, true);
},
.exited => |e| if (p.panes[e.pane]) |pane| {
if (pane.command == null)
@@ -6474,6 +6496,11 @@ pub const Pardes = struct {
const wait = Messages.messageWake(p, pane) orelse continue;
frames = if (frames) |soonest| @min(soonest, wait) else wait;
};
+ // A paste's Enter waiting on its REPL goes at the end of its wait.
+ for (p.panes) |slot| if (slot) |pane| if (pane.repl_enter > 0) {
+ const wait = @max(1, (pane.repl_enter_due_ns -| p.stepped_ns) / animation.frame_ns);
+ frames = if (frames) |soonest| @min(soonest, wait) else wait;
+ };
return if (frames) |n| p.stepped_ns + n * animation.frame_ns else null;
}