summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 21:44:15 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitdd71a3433fa026794ffc5cc1dd3435984f693540 (patch)
treeef8ae9467e99e1a362a9d3ea311361780c8d8277 /src/exec.zig
parent86ce788e925bd19297213ef14cf02fa564ae9f10 (diff)
downloadpardes-dd71a3433fa026794ffc5cc1dd3435984f693540.tar.gz
pardes-dd71a3433fa026794ffc5cc1dd3435984f693540.zip
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 <[email protected]>
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);