summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/look.zig7
-rw-r--r--src/ninep/ctl.zig19
2 files changed, 23 insertions, 3 deletions
diff --git a/src/look.zig b/src/look.zig
index 79cbd50d..a29b27b5 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1334,11 +1334,14 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
};
if (!by_serial and path.len > 0 and (f.output != null or !std.mem.endsWith(u8, f.path, std.fs.path.basename(path)))) return;
var a: Addr = .{ .text = f.content, .lim = null, .expr = expr };
+ // A miss names the file it was looked for in, and is that file's pane's.
+ var cut: [miss_path_cap + "…".len]u8 = undefined;
+ const name = missText(f.path, &cut);
const r = a.address(ninep_pane.dotOf(pane)) orelse {
- return missed(p, id, "{s}", .{a.err});
+ return missed(p, target, "{s}: {s}", .{ name, a.err });
};
if (a.i < expr.len or r.q0 > r.q1) {
- return missed(p, id, "{s}", .{if (r.q0 > r.q1) "addresses out of order" else "bad address syntax"});
+ return missed(p, target, "{s}: {s}", .{ name, if (r.q0 > r.q1) "addresses out of order" else "bad address syntax" });
}
clearNavigationSelection(p, pane);
ninep_pane.setDot(pane, r);
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 1ac53bb7..d2ff4dab 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2252,6 +2252,23 @@ test "Mini with no argument is wrong #args, EINVAL, as every word that needs one
try testing.expectEqualStrings("wrong #args in control message \"Mini\"", r.reply.ename);
}
+test "a look that misses file:/re/ names the file, and is logged as its pane's" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "f.txt", .data = "alpha\n" });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/f.txt\n", .{dir}));
+ p.sync();
+ const f_serial = p.panes[p.active].?.serial;
+ _ = wr(p, Node.of(serialOf(p), .look), try std.fmt.bufPrint(&line, "{s}/f.txt:/zzqq/\n", .{dir}));
+ var want: [4300]u8 = undefined;
+ try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "err {d} look: {s}/f.txt: no match for regexp", .{ f_serial, dir })));
+}
+
test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
@@ -2978,7 +2995,7 @@ test "@p<serial>:<address> takes any sam address; a miss and an unknown serial a
}
var line: [64]u8 = undefined;
_ = wr(p, root, try std.fmt.bufPrint(&line, "@p{d}:/zzqq/\n", .{serial}));
- try testing.expect(th.logHas(p, "look: no match for regexp"));
+ try testing.expect(th.logHas(p, ": no match for regexp"));
try testing.expectEqualStrings("", rd(p, root, 0, 64).bytes);
_ = wr(p, root, "@p999:/foo/\n");
try testing.expect(th.logHas(p, "look: no pane @p999"));