summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/look.zig b/src/look.zig
index 105b7717..f208c1fb 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1455,11 +1455,17 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
// 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);
+ // A look whose address fails opens nothing: a pane it opened to read
+ // the address in goes again, the miss said from the pane it came from.
+ const opened_here = open == null and target != id;
const r = a.address(ninep_pane.dotOf(pane)) orelse {
+ if (opened_here) return closeAndMiss(p, id, target, name, a.err);
return missed(p, target, "{s}: {s}", .{ name, a.err });
};
if (a.i < expr.len or r.q0 > r.q1) {
- return missed(p, target, "{s}: {s}", .{ name, if (r.q0 > r.q1) "addresses out of order" else "bad address syntax" });
+ const why = if (r.q0 > r.q1) "addresses out of order" else "bad address syntax";
+ if (opened_here) return closeAndMiss(p, id, target, name, why);
+ return missed(p, target, "{s}: {s}", .{ name, why });
}
clearNavigationSelection(p, pane);
ninep_pane.setDot(pane, r);
@@ -1481,6 +1487,14 @@ fn lookPdfPage(p: *Pardes, id: usize, target: usize, pv: anytype, expr: []const
p.active = target;
}
+fn closeAndMiss(p: *Pardes, id: usize, opened: usize, name: []const u8, why: []const u8) void {
+ var kept: [miss_path_cap + "…".len]u8 = undefined;
+ @memcpy(kept[0..name.len], name);
+ p.removePane(opened, null) catch {};
+ if (p.panes[id] != null) p.active = id;
+ missed(p, id, "{s}: {s}", .{ kept[0..name.len], why });
+}
+
/// `@p<terminal>:<address>`: any address over the terminal's body as its
/// logical lines read (the lines a +Search lists as `@p<serial>:<line>`),
/// from its cursor; the match is selected there, as a +Search row's is.
@@ -1672,7 +1686,9 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
};
// The operand may borrow selected terminal/PDF text released below.
const txt = p.scratch.allocator().dupe(u8, looked) catch return;
- const trimmed = std.mem.trim(u8, txt, " \t\r\n");
+ // A trailing `:` (`a.txt:2:3:`, as a compiler's message ends) is no
+ // part of the place, as a click's expansion leaves it off.
+ const trimmed = std.mem.trimEnd(u8, std.mem.trim(u8, txt, " \t\r\n"), ":");
// acme's `file:addr` and `:addr` (look.c:450-543): an address after
// the colon, evaluated in that file from its dot (openfile, look.c:675).
// `file:3:0`, and `file:0:0` too: columns count from 1, as addr's do,