summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig40
1 files changed, 39 insertions, 1 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 9e6183a1..86f8d8cb 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -7320,7 +7320,10 @@ test "a client's n in a kind's pane is a motion: it steps to the next place a re
/// `addon`: a kind whose state is its own on the session (a PDF's), which
/// the walk does not stand in (its Still has no search, place or word):
/// the soak's (test/replicas.zig) PDF and pictures are, judged by name.
-const On = enum { any, file, kind, shell, shell_normal, addon, dir };
+/// `command`: a pane in a directory with a finished command pane, which a
+/// line run there runs in again (exec.runCommand); the walk stands in none:
+/// the soak's are, judged by name, and the test after the walk.
+const On = enum { any, file, kind, shell, shell_normal, addon, dir, command };
/// What a far client may wait a round trip for (the user's line, P14: a
/// side effect on the system may be slow; motions, edits and layout are
@@ -7354,6 +7357,7 @@ const may_wait = [_]Wait{
.{ .what = "Find *", .on = .any, .stop = "kind", .why = "the work tree it lists from, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the listing itself is the session's" },
.{ .what = "Grep *", .on = .any, .stop = "kind", .why = "the work tree it searches, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the search itself is the session's" },
.{ .what = "Exec *", .on = .any, .stop = "tty_taken", .why = "a program run in a shell: whether one has it, the session's" },
+ .{ .what = "Exec *", .on = .command, .stop = "run a command", .why = "a line run again in its directory's finished command pane: its process and its emulator are the session's" },
.{ .what = "Term", .on = .any, .stop = "kind", .why = "a shell opened: its name asked of the disk first" },
.{ .what = "A-n", .on = .any, .stop = "open a terminal", .why = "a shell opened" },
.{ .what = "* A-n", .on = .any, .stop = "open a terminal", .why = "a shell opened (Alt-n after a prefix is still the global key)" },
@@ -7717,6 +7721,40 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell'
try std.testing.expectEqual(@as(u32, 0), stale);
}
+test "a far client's line run again in its directory's finished command pane waits for the session's order, at a stop may_wait lists: its process and its emulator are the session's" {
+ // The soak's (test/replicas.zig, seed 3 rtt 80): a client's key stopped
+ // at `spawn`, which may_wait does not list. Its speculation ran the
+ // reused pane's whole run (exec.runCommand): the emulator's writes
+ // refused (`a terminal's output`), then the spawn effect (a host entry
+ // that keeps stopping), the last one naming the stop.
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane's terminal
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host());
+ defer a.deinit();
+ const file = a.core.view().active;
+ _ = try a.local(.{ .command = "Exec true" });
+ const cmd = for (a.core.panes, 0..) |slot, id| {
+ if (slot) |pane| if (pane.command != null) break id;
+ } else return error.NoCommandPane;
+ _ = try a.local(.{ .exited = .{ .pane = .at(cmd), .status = 0 } });
+ _ = try a.local(.{ .eof = .{ .pane = .at(cmd) } });
+ try std.testing.expect(a.core.panes[cmd].?.command_done);
+ a.core.view().active = file;
+ const r = try joinedFresh(a);
+ defer r.deinit();
+ // The same line from the file's pane: its directory's finished pane runs it.
+ const stopped = r.stats.stopped;
+ const msg = try gpa.dupe(u8, try r.input(.{ .command = "Exec true" }));
+ defer gpa.free(msg);
+ try std.testing.expectEqual(stopped + 1, r.stats.stopped);
+ if (!mayWait(r.t.poisoned_by)) std.debug.print("stopped at `{s}`\n", .{r.t.poisoned_by});
+ try std.testing.expect(mayWait(r.t.poisoned_by));
+ r.confirm(try a.take(msg));
+ r.settle();
+ try agrees(a, r);
+ try std.testing.expect(!a.core.panes[cmd].?.command_done);
+}
+
test "a far client's click into a shell whose program asked for focus events is instant: the session's step tells the program, a round trip later, and the client's guess is confirmed" {
if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const gpa = std.testing.allocator;