summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig15
1 files changed, 7 insertions, 8 deletions
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);