summaryrefslogtreecommitdiff
path: root/src/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-15 18:27:49 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit4a3c5a48224cf542429504e8728e10c802e1fd52 (patch)
tree92b9b0922d8e37abd0af68cc014433449be29f05 /src/panes.zig
parentf3a9a1a9005024923f32e1acae5ecd509e9bbfd2 (diff)
downloadpardes-4a3c5a48224cf542429504e8728e10c802e1fd52.tar.gz
pardes-4a3c5a48224cf542429504e8728e10c802e1fd52.zip
Highlight exact source occurrences in LSP references and goto results
Diffstat (limited to 'src/panes.zig')
-rw-r--r--src/panes.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/panes.zig b/src/panes.zig
index 315b0b0f..7855866d 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -2205,12 +2205,16 @@ pub const Output = struct {
const source_start = if (metadata) |m| m.code_start else target.code_start;
if (source_start >= line.len) return row;
if (metadata) |m| if (m.kind == .context) return row;
- const is_search = switch (origin) {
+ const mark_occurrence = switch (origin) {
.search => true,
.cmd => |cmd| cmd == .Grep,
+ .query => |kind| switch (kind) {
+ .definition, .declaration, .type_definition, .implementation, .references => true,
+ else => false,
+ },
else => false,
};
- if (is_search and spot.col > 0 and spot.end_line == spot.line and
+ if (mark_occurrence and spot.col > 0 and spot.end_line == spot.line and
spot.end_col >= spot.col)
{
row.mark_start = source_start +| (spot.col - 1);
@@ -2243,6 +2247,15 @@ pub const Output = struct {
try std.testing.expectEqualStrings("warning:", "src/a.rs:3:5-7 warning: unused"[diagnostic.mark_start..diagnostic.mark_end]);
const malformed = rowDecoration(.{ .from = .search }, "src/a.rs:3:99999999999999999999-99999999999999999999 text");
try std.testing.expect(malformed.mark_end <= "src/a.rs:3:99999999999999999999-99999999999999999999 text".len);
+ const snippet = "src/a.rs:3:14-16 \t\tfoo + 界 + foo";
+ for ([_]lsp.Kind{ .definition, .declaration, .type_definition, .implementation, .references }) |kind| {
+ const occurrence = rowDecoration(.{ .from = .{ .query = kind } }, snippet);
+ try std.testing.expectEqualStrings("foo", snippet[occurrence.mark_start..occurrence.mark_end]);
+ }
+ for ([_]lsp.Kind{ .document_symbols, .workspace_symbols, .completion, .incoming_calls, .outgoing_calls, .supertypes, .subtypes, .rename }) |kind| {
+ const label = rowDecoration(.{ .from = .{ .query = kind } }, snippet);
+ try std.testing.expectEqual(@as(usize, 0), label.mark_end);
+ }
}
test "plain output does not opt into location decoration" {