summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig31
1 files changed, 30 insertions, 1 deletions
diff --git a/core/replica.zig b/core/replica.zig
index dc5d99a4..5ce8454e 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -5062,7 +5062,8 @@ const SeenHost = struct {
of(ctx).linked += 1;
}
fn watchTheme(_: ?*anyopaque, _: u32, _: bool) void {}
- const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .set_clipboard = setClipboard, .read_clipboard = readClipboard, .open_link = openLink, .watch_theme = watchTheme };
+ fn watchFile(_: ?*anyopaque, _: u8, _: []const u8, _: bool, _: pardes.WatchMode) void {}
+ const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .set_clipboard = setClipboard, .read_clipboard = readClipboard, .open_link = openLink, .watch_theme = watchTheme, .watch_file = watchFile };
fn host(h: *SeenHost) pardes.Host {
return .{ .ctx = h, .vtable = &vtable };
}
@@ -5163,3 +5164,31 @@ test "a client's yank and paste of the system clipboard are its own frontend's:
_ = try a.own(.{ .command = "ClipYank" });
try std.testing.expectEqual(@as(u32, 1), h.yanked);
}
+
+test "a client's own Zerox and Del of a file pane are instant: what Recent keeps of the file is what its open learned, not a question to the disk; Recent has its place as the session's always did" {
+ const gpa = std.testing.allocator;
+ var h: SeenHost = .{};
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, h.host(), false);
+ defer a.deinit();
+ h.core = a.core;
+ var cwd: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ var line: [std.Io.Dir.max_path_bytes + 32]u8 = undefined;
+ var path_buf: [std.Io.Dir.max_path_bytes + 32]u8 = undefined;
+ const dir = std.mem.span(@as([*:0]u8, @ptrCast(std.c.getcwd(&cwd, cwd.len) orelse return error.NoCwd)));
+ const path = try std.fmt.bufPrint(&path_buf, "{s}/build.zig.zon", .{dir});
+ _ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{path}) });
+ const r = try joinedFresh(a);
+ defer r.deinit();
+ // The twin, then each closed: the twin, the file.
+ for ([_][]const u8{ "Zerox", "Del", "Del" }) |cmd| {
+ const msg = try gpa.dupe(u8, try r.input(.{ .command = cmd }));
+ defer gpa.free(msg);
+ try std.testing.expectEqual(@as(usize, 1), r.applied);
+ r.confirm(try a.take(msg));
+ r.settle();
+ try agrees(a, r);
+ }
+ try std.testing.expectEqual(@as(u32, 0), r.stats.stopped);
+ try std.testing.expectEqual(@as(u32, 0), r.stats.mispredicted);
+ try std.testing.expect(a.core.recent.get(path) != null);
+}