summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/exec.zig b/src/exec.zig
index 5b170375..ac6efcdd 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -554,16 +554,21 @@ 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.
+ // Every REPL bound for the language whose program still runs: one
+ // whose program exited is skipped, in the question and in the choice.
var bound: [26]usize = undefined;
var n: usize = 0;
+ var exited: ?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)) {
+ exited = i;
+ continue;
+ }
bound[n] = i;
n += 1;
};
- if (n == 0) return .none;
+ // Bound but none running: said, never run as a command instead.
+ if (n == 0) return if (exited) |i| replGone(p, from, p.panes[i].?) else .none;
if (n == 1) {
if (!replLive(p, bound[0])) return replGone(p, from, p.panes[bound[0]].?);
sendToRepl(p, from, bound[0], text);