summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 18:13:43 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit09ef40318a3a3d1b9494e2a5fa41f71363929676 (patch)
tree2f01fa0ff91e1f9341b90f41acd03b72c2604da1 /src/ninep
parent01bf4ed09423b3c7e01598ff3a844cc3c12c3ff2 (diff)
downloadpardes-09ef40318a3a3d1b9494e2a5fa41f71363929676.tar.gz
pardes-09ef40318a3a3d1b9494e2a5fa41f71363929676.zip
One look logs one err: a file:addr whose file is not there is one miss quoting what was written, and a refused placement is the look's only failure
A look at utf8txt:#3 from a terminal searched for utf8txt, missed, then found the terminal no text to address: two errs for one write. It is now looked for whole, as zzq:2 already was, so every form's miss reads no match for "<as written>". A look whose new pane was refused a place went on to settle its line in the pane it stayed on and logged has no line N after the placement failure; it now stops there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig33
-rw-r--r--src/ninep/testing.zig7
2 files changed, 39 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 59a80f36..5bf354eb 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1752,6 +1752,39 @@ test "a look after Newcol fills the empty column the keyboard is on" {
try testing.expectEqual(p.active, p.col_panes[p.ncol - 1][0]);
}
+test "a look at file:addr whose file is not there is one miss, quoting what was written, in a terminal too" {
+ const p = try th.withTerm(testing.allocator);
+ defer p.deinit();
+ const looked = Node.of(serialOf(p), .look);
+ for ([_][]const u8{ "zzq:#3", "zzq:2", "zzq:/re/" }) |written| {
+ var line: [64]u8 = undefined;
+ _ = wr(p, looked, try std.fmt.bufPrint(&line, "{s}\n", .{written}));
+ var want: [64]u8 = undefined;
+ try testing.expectEqual(@as(usize, 1), th.logCount(p, try std.fmt.bufPrint(&want, "look: no match for \"{s}\"\n", .{written})));
+ }
+ try testing.expectEqual(@as(usize, 3), th.logCount(p, "\nerr "));
+}
+
+test "a look whose pane is refused a place fails with that alone, not a missing line too" {
+ const gpa = testing.allocator;
+ // A screen with rows for one pane only.
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 5 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ _ = try p.setTestFile("x\n");
+ while (p.nextEffect()) |_| {}
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "f.txt", .data = "one\ntwo\n" });
+ var dir: [4096]u8 = undefined;
+ const at = dir[0..try tmp.dir.realPath(testing.io, &dir)];
+ var line: [4200]u8 = undefined;
+ const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/f.txt:2\n", .{at}));
+ try testing.expectEqual(Status.err, r.reply.status);
+ try testing.expect(std.mem.indexOf(u8, r.reply.ename, "no space for a pane") != null);
+ try testing.expectEqual(@as(usize, 1), th.logCount(p, "\nerr "));
+}
+
test "a look under pardes's placement, from a pane pane/new made after Delcol, opens its file" {
const gpa = testing.allocator;
const p = try withFile(gpa, "x\n");
diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig
index 927552e2..b8eaa02b 100644
--- a/src/ninep/testing.zig
+++ b/src/ninep/testing.zig
@@ -58,11 +58,16 @@ pub fn rd(p: *Pardes, node: u64, off: u64, size: u32) Answer {
/// Whether the log, read whole from a fresh open, holds `needle`.
pub fn logHas(p: *Pardes, needle: []const u8) bool {
+ return logCount(p, needle) > 0;
+}
+
+/// How many times the log, read whole from a fresh open, holds `needle`.
+pub fn logCount(p: *Pardes, needle: []const u8) usize {
const log = @intFromEnum(tree.TopFile.log);
const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
defer _ = call(p, .{ .tag = 3, .op = .release, .node = log, .handle = h });
const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes;
- return std.mem.indexOf(u8, text, needle) != null;
+ return std.mem.count(u8, text, needle);
}
pub fn wr(p: *Pardes, node: u64, data: []const u8) Answer {