From dd71a3433fa026794ffc5cc1dd3435984f693540 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 21:44:15 -0300 Subject: With several REPLs bound for a language the pane always asks which, as documented, whether or not a program runs in each Only REPLs with a program running were counted, so with two bound and one at its shell prompt the text went to the other without a word, and which REPL got it depended on what happened to be running. All bound REPLs are offered now; one chosen with no program running is sent nothing and says so. Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 4472df8f..1e5282da 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1717,14 +1717,20 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe try std.testing.expect(p.executeBuiltinLine(2, "Repl python")); try std.testing.expectEqualStrings("python-b", exec.replId(&idbuf, p.panes[2].?)); - // A REPL whose program has left (Ctrl-D: the shell has the tty) is - // sent nothing, and nothing runs: it says so. + // Two bound always ask, whichever has a program running: one left + // (Ctrl-D: the shell has the tty) is still offered, and chosen, it is + // sent nothing, nothing runs, and that is said. host.taken[1] = false; - host.taken[2] = false; _ = exec.executeFrom(p, 0, "import os", true); + try std.testing.expectEqual(Pane.Prompt.repl_choice, file.prompt); + p.update(.{ .key = .{ .cp = 'a' } }); Sent.drain(p); try std.testing.expect(Sent.len[1] == 0 and Sent.len[2] == 0 and !Sent.spawned); try std.testing.expect(std.mem.indexOf(u8, file.msg[0..file.msg_len], "no program running") != null); + host.taken[2] = false; + _ = exec.executeFrom(p, 0, "import os", true); + try std.testing.expectEqual(Pane.Prompt.repl_choice, file.prompt); + p.update(.{ .key = .{ .cp = Key.escape } }); host.taken[1] = true; host.taken[2] = true; @@ -6047,7 +6053,12 @@ pub const Pardes = struct { // The pane offered, still that REPL and still running: it // may have closed or been rebound while the question stood. if (p.paneBySerial(serial)) |to| if (p.panes[to].?.repl) |r| - if (r.lang == ask.lang and r.letter == letter and exec.replLive(p, to)) { + if (r.lang == ask.lang and r.letter == letter) { + // Offered with no program running: said so, not sent. + if (!exec.replLive(p, to)) { + _ = exec.replGone(p, id, p.panes[to].?); + return true; + } exec.sendToRepl(p, id, to, ask.text); return true; }; -- cgit v1.3