diff options
Diffstat (limited to 'src/panes.zig')
| -rw-r--r-- | src/panes.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/panes.zig b/src/panes.zig index f07e63c3..e21b1dc4 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -1064,6 +1064,7 @@ pub const File = struct { const saved = try arena.alloc(dump.LocationRow, rows.len); for (rows, saved) |row, *out| out.* = .{ .kind = @enumFromInt(@intFromEnum(row.kind)), + .declaration = row.declaration, .path = row.path, .line = row.at.line, .col = row.at.col, @@ -1094,7 +1095,8 @@ pub const File = struct { if (row.path.len == 0 or row.path.len >= 4096 or row.location_end > row.code_start or row.code_start == 0 or row.code_start > line.len or line[row.code_start - 1] != '\t' or - (row.kind == .context) != std.mem.startsWith(u8, line, locations.context_prefix) or + (row.kind == .context) != locations.isContextLine(line) or + (row.declaration and row.kind != .context) or row.line > std.math.maxInt(i32) or row.col > std.math.maxInt(i32) or row.end_line > std.math.maxInt(i32) or row.end_col > std.math.maxInt(i32)) return error.InvalidLocationRows; @@ -1107,6 +1109,7 @@ pub const File = struct { const path = try gpa.dupe(u8, row.path); out.* = .{ .kind = @enumFromInt(@intFromEnum(row.kind)), + .declaration = row.declaration, .path = path, .at = .{ .line = row.line, .col = row.col, .end_line = row.end_line, .end_col = row.end_col }, .location_end = row.location_end, @@ -2151,6 +2154,8 @@ pub const Output = struct { const RowDecoration = struct { location_end: usize = 0, + prefix_end: usize = 0, + declaration: bool = false, mark_start: usize = 0, mark_end: usize = 0, severity: enum { none, err, warning, info, hint } = .none, @@ -2159,7 +2164,8 @@ pub const Output = struct { // Body paper changes immediately, so its ink must change with it // even while the surrounding tags are still fading. const chrome = pardes.ChromeTheme.fromTheme(p.theme()); - if (byte < row.location_end) return .{ .fg = .{ .rgb = chrome.lineno } }; + if (row.declaration or byte < @max(row.location_end, row.prefix_end)) + return .{ .fg = .{ .rgb = chrome.lineno } }; if (byte < row.mark_start or byte >= row.mark_end) return null; if (row.severity == .none) return .{ .fg = .{ .rgb = chrome.search_fg }, @@ -2184,7 +2190,11 @@ pub const Output = struct { const target = locations.parse(line); const spot = if (metadata) |m| m.at else target.at; if (spot.line == 0) return .{}; - var row: RowDecoration = .{ .location_end = if (metadata) |m| m.location_end else target.end }; + var row: RowDecoration = .{ + .location_end = if (metadata) |m| m.location_end else target.end, + .prefix_end = if (metadata) |m| m.code_start else target.end, + .declaration = if (metadata) |m| m.declaration else false, + }; 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; @@ -2341,7 +2351,7 @@ pub const Output = struct { pub fn isResultRow(file: *const File.State, row: usize) bool { if (row < file.location_rows.len) return file.location_rows[row].kind == .match; - return !std.mem.startsWith(u8, modal.lineSlice(file.content, row), locations.context_prefix); + return !locations.isContextLine(modal.lineSlice(file.content, row)); } fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?usize) !?usize { @@ -2438,7 +2448,7 @@ pub const Output = struct { var first: ?usize = null; var row: usize = 0; while (lines.next()) |line| : (row += 1) { - if (std.mem.startsWith(u8, line, locations.context_prefix)) continue; + if (locations.isContextLine(line)) continue; const target = location(line); if (target.at.line == 0) continue; if (first == null) first = row; |
