diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pardes.zig | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 1e5282da..47ebf8fa 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6716,7 +6716,21 @@ pub const Pardes = struct { const nrows = std.mem.count(u8, rows, "\n"); if (panes.Output.traits(from).jumps and nrows == 1) { const ln = std.mem.trimEnd(u8, rows, "\n"); - return look.lookAt(p, w.pane, ln[0..panes.Output.location(ln).end]); + const place = ln[0..panes.Output.location(ln).end]; + p.look_missed = false; + look.lookAt(p, w.pane, place); + // A word that asks for a list (Callers, Refs) with one answer + // jumps to it with no list: where it went is said, as the list + // would have shown it. A definition's jump is the answer itself. + const listing = switch (w.kind) { + .references, .incoming_calls, .outgoing_calls, .supertypes, .subtypes => true, + else => false, + }; + if (listing and !p.look_missed) { + var where: [300]u8 = undefined; + p.setMessage(p.active, std.fmt.bufPrint(&where, "{s}: the one, {s}", .{ lspWord(w.kind), place[0..@min(place.len, 240)] }) catch lspWord(w.kind)); + } + return; } const dir = if (pane.file) |f| (std.fs.path.dirname(f.path) orelse "/") else pane.cwdSlice(); @@ -8097,6 +8111,18 @@ test "the jump list never holds two entries in a row the same, when the one betw try std.testing.expectEqual(@as(u32, 150), p.jumps[1].line); } +test "Callers with one answer jumps to it and says where, in a msg" { + if (!lsp.supports.contains(.incoming_calls)) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const pane = try p.setTestFile("fn a() {}\nfn b() { a(); }\n"); + p.lspRequest(p.active, .incoming_calls, ""); + const wait = p.lsp_wait.?; + p.update(.{ .lsp_resp = .{ .id = wait.id, .rows = "/test.txt:2:10 b\n" } }); + try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row); + try std.testing.expectEqualStrings("Callers: the one, /test.txt:2:10", pane.msg[0..pane.msg_len]); +} + test "a Rename the language server finds nothing for says so, and changes nothing" { if (!lsp.supports.contains(.rename)) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); |
