summaryrefslogtreecommitdiff
path: root/src/lsp/lsp_client.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/lsp/lsp_client.zig')
-rw-r--r--src/lsp/lsp_client.zig14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lsp/lsp_client.zig b/src/lsp/lsp_client.zig
index 7704d0ad..0c5e3b7e 100644
--- a/src/lsp/lsp_client.zig
+++ b/src/lsp/lsp_client.zig
@@ -405,8 +405,9 @@ const Trace = struct {
// ------------------------------------------------------------------- query
-pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: lsp.Req, out: *std.Io.Writer) !void {
+pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, asked: lsp.Req, out: *std.Io.Writer) !void {
_ = gpa;
+ const req = lsp.explaining(asked);
if (req.kind == .status) return status(req, out);
var tr: Trace = .{ .on = req.kind == .explain };
@@ -443,8 +444,8 @@ pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: lsp.Req, out
fn traceOut(tr: *const Trace, req: lsp.Req, out: *std.Io.Writer, rows: usize, us: u64) std.Io.Writer.Error!void {
if (req.kind != .explain) return;
- try out.print("lsp explain — the definition query at byte {d} of {s}\n\n", .{
- req.offset, if (req.path.len == 0) "(no file)" else std.fs.path.basename(req.path),
+ try out.print("lsp explain — the {s} query at byte {d} of {s}\n\n", .{
+ @tagName(req.explains), req.offset, if (req.path.len == 0) "(no file)" else std.fs.path.basename(req.path),
});
try out.writeAll(tr.buf[0..tr.len]);
if (hideTime())
@@ -488,9 +489,10 @@ fn answer(arena: std.mem.Allocator, si: usize, req: lsp.Req, out: *std.Io.Writer
}
fn run(c: *Conn, si: usize, arena: std.mem.Allocator, req: lsp.Req, out: *std.Io.Writer, tr: *Trace) Err!void {
- // `explain` narrates the definition query — dispatch below on the
- // effective kind so the trace follows the code `gd` really runs.
- const kind: lsp.Kind = if (req.kind == .explain) .definition else req.kind;
+ // `explain` narrates the last query asked (a definition, `gd`, when
+ // none was) — dispatch below on the effective kind so the trace
+ // follows the code that query really runs.
+ const kind: lsp.Kind = if (req.kind == .explain) req.explains else req.kind;
// Both arg-taking kinds are useless without one, and an empty
// workspace/symbol query means "every symbol in the project".