summaryrefslogtreecommitdiff
path: root/src/lsp/Ask.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/lsp/Ask.zig')
-rw-r--r--src/lsp/Ask.zig29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lsp/Ask.zig b/src/lsp/Ask.zig
index f071cf7b..8ed0aecc 100644
--- a/src/lsp/Ask.zig
+++ b/src/lsp/Ask.zig
@@ -264,6 +264,7 @@ fn lspWord(kind: lsp.Kind) []const u8 {
}
pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
+ const v = p.view();
defer pardes.turn.bump(&pardes.turn.lsp_answers);
const w = p.lsp_ask.wait orelse return;
if (w.id != id) return; // superseded by a newer press, or the pane died
@@ -332,7 +333,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
// The one place is the text's places, as a list's would be: tinted,
// and n and N step it.
const spot = look.parsePathLine(place);
- if (!p.look_missed and spot.at.line > 0) if (p.panes[p.active]) |there| if (there.file) |*tf| if (spot.at.line <= panes.File.nlines(p.gpa, tf)) {
+ if (!p.look_missed and spot.at.line > 0) if (p.panes[v.active]) |there| if (there.file) |*tf| if (spot.at.line <= panes.File.nlines(p.gpa, tf)) {
const ls = panes.File.lineStart(p.gpa, tf, spot.at.line - 1);
const line = tf.content[ls .. std.mem.indexOfScalarPos(u8, tf.content, ls, '\n') orelse tf.content.len];
const col = @min(spot.at.col -| 1, line.len);
@@ -349,7 +350,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
};
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));
+ p.setMessage(v.active, std.fmt.bufPrint(&where, "{s}: the one, {s}", .{ lspWord(w.kind), place[0..@min(place.len, 240)] }) catch lspWord(w.kind));
}
return;
}
@@ -387,7 +388,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void {
if (result_pane.serial != p.fs.lsp_result) continue;
if (p.next_serial != serial_before) {
const report_rows = std.mem.count(u8, result_pane.file.?.content, "\n");
- const wanted: u16 = @intCast(@min(p.screen_h, report_rows + result_pane.tag_rows));
+ const wanted: u16 = @intCast(@min(v.screen_h, report_rows + result_pane.tag_rows));
layout.givePaneRows(p, result_id, wanted, w.pane);
}
look.focusPaneLine(p, result_id, .{ .line = 1, .col = 1 }, .keep);
@@ -488,7 +489,7 @@ test "Def and Refs are a speaking file's tag words; gd, gr and a 2-1 chord all r
p.update(.{ .key = .{ .cp = 'c' } });
try std.testing.expectEqual(@as(u32, 8), try Asked.one(p, .callstack));
- const r = p.rects[0];
+ const r = p.view().rects[0];
const x0 = r.x + config.GUTTER + panes.File.gutterWidth(pane);
const use_y = p.bodyTop(pane, r) + 1;
// Copied out of the scratch arena, which each p.update resets.
@@ -530,7 +531,7 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy
p.lspRequest(0, .callstack, "");
const first = p.lsp_ask.wait orelse return error.NoRequest;
lspResponse(p, first.id, "╰──┬ /test.txt:1:4-7 work\n@callstack-match ╰─ /test.txt:1:4-7 fn work() {}\n");
- const report = p.panes[p.active].?;
+ const report = p.panes[p.view().active].?;
try std.testing.expect(report != source);
try std.testing.expect(std.mem.endsWith(u8, report.file.?.path, "/+Callstack"));
try std.testing.expectEqual(@as(i32, 0), source.body.cur_row);
@@ -541,22 +542,22 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy
defer frame.deinit();
const surface = try p.render(frame.allocator());
p.presented();
- const r = p.rects[p.active];
+ const r = p.view().rects[p.view().active];
const row = r.y + report.tag_rows;
const col = r.x + config.GUTTER + panes.File.gutterWidth(report) + 7;
try std.testing.expectEqual(.off, surface.at(col, row).style.ul);
p.update(.{ .mouse = .{ .button = .right, .kind = .press, .row = row, .col = col } });
p.update(.{ .mouse = .{ .button = .right, .kind = .release, .row = row, .col = col } });
try std.testing.expect(!source.collapsed);
- try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(@as(usize, 0), p.view().active);
try std.testing.expect(!report.body.vsel.active);
try std.testing.expectEqual(@as(usize, 0), report.body.nsel);
const serial = report.serial;
p.lspRequest(0, .callstack, "");
const second = p.lsp_ask.wait orelse return error.NoRequest;
lspResponse(p, second.id, "No callers reported\n");
- try std.testing.expectEqual(serial, p.panes[p.active].?.serial);
- try std.testing.expectEqualStrings("No callers reported\n", p.panes[p.active].?.file.?.content);
+ try std.testing.expectEqual(serial, p.panes[p.view().active].?.serial);
+ try std.testing.expectEqualStrings("No callers reported\n", p.panes[p.view().active].?.file.?.content);
}
test "Callers with one answer jumps to it and says where, in a msg" {
@@ -564,7 +565,7 @@ test "Callers with one answer jumps to it and says where, in a msg" {
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, "");
+ p.lspRequest(p.view().active, .incoming_calls, "");
const wait = p.lsp_ask.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);
@@ -576,7 +577,7 @@ test "a Rename the language server finds nothing for says so, and changes nothin
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
const pane = try p.setTestFile("const value=1;\n");
- p.lspRequest(p.active, .rename, "renamed");
+ p.lspRequest(p.view().active, .rename, "renamed");
const wait = p.lsp_ask.wait.?;
p.update(.{ .lsp_resp = .{ .id = wait.id, .rows = "" } });
try std.testing.expectEqualStrings("Rename: nothing here to rename", pane.msg[0..pane.msg_len]);
@@ -591,9 +592,9 @@ test "LSP failure clears only its matching wait without completion indentation"
pane.body.mode = .insert;
pane.body.cur_col = 1;
- p.lspRequest(p.active, .completion, "");
+ p.lspRequest(p.view().active, .completion, "");
const old_id = p.lsp_ask.wait.?.id;
- p.lspRequest(p.active, .completion, "");
+ p.lspRequest(p.view().active, .completion, "");
const current_id = p.lsp_ask.wait.?.id;
p.update(.{ .lsp_resp = .{ .id = old_id, .rows = null } });
try std.testing.expectEqual(current_id, p.lsp_ask.wait.?.id);
@@ -602,7 +603,7 @@ test "LSP failure clears only its matching wait without completion indentation"
try std.testing.expectEqualStrings("x", pane.file.?.content);
try std.testing.expectEqual(@as(i32, 1), pane.body.cur_col);
- p.lspRequest(p.active, .completion, "");
+ p.lspRequest(p.view().active, .completion, "");
p.update(.{ .lsp_resp = .{ .id = p.lsp_ask.wait.?.id, .rows = "" } });
try std.testing.expect(p.lsp_ask.wait == null);
try std.testing.expectEqualStrings("x ", pane.file.?.content);