diff options
Diffstat (limited to 'src/panes.zig')
| -rw-r--r-- | src/panes.zig | 17 |
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" { |
