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/exec.zig | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index 2b3ca40c..104e3b4d 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -522,7 +522,7 @@ const Routed = union(enum) { none, sent: usize, asked }; /// The REPL bound here has no program running to take the text: said, /// and nothing sent or run. -fn replGone(p: *Pardes, from: usize, repl: *const Pane) Routed { +pub fn replGone(p: *Pardes, from: usize, repl: *const Pane) Routed { var idbuf: [48]u8 = undefined; var said: [128]u8 = undefined; p.setMessage(from, std.fmt.bufPrint(&said, "Repl: {s} has no program running; nothing sent", .{replId(&idbuf, repl)}) catch "Repl: no program running"); @@ -539,23 +539,22 @@ fn routeToRepl(p: *Pardes, from: usize, text: []const u8) Routed { return .{ .sent = from }; } const lang = langOf(src) orelse return .none; + // Every REPL bound for the language, a program running in it or not: + // which one is the text's is never guessed from which happens to be + // running now. var bound: [26]usize = undefined; var n: usize = 0; - var gone: ?usize = null; for (p.panes, 0..) |slot, i| if (slot) |pane| if (pane.repl) |r| if (r.lang == lang and n < bound.len) { - if (!replLive(p, i)) { - gone = i; - continue; - } bound[n] = i; n += 1; }; - if (n == 0) return if (gone) |i| replGone(p, from, p.panes[i].?) else .none; + if (n == 0) return .none; if (n == 1) { + if (!replLive(p, bound[0])) return replGone(p, from, p.panes[bound[0]].?); sendToRepl(p, from, bound[0], text); return .{ .sent = bound[0] }; } - // Several: asked on the pane's notice band, as Del asks, one key + // Several: always asked on the pane's notice band, as Del asks, one key // answering; nothing is remembered of the answer. const owned = p.gpa.dupe(u8, text) catch return .none; if (p.repl_ask) |old| p.gpa.free(old.text); -- cgit v1.3