summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/locations.zig8
-rw-r--r--src/panes.zig8
-rw-r--r--src/pardes.zig2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/locations.zig b/src/locations.zig
index 61bbbd1a..5e588dbe 100644
--- a/src/locations.zig
+++ b/src/locations.zig
@@ -5,10 +5,10 @@ const syntax = @import("syntax.zig");
const filesystem = @import("fs.zig");
pub const Config = @import("locations_config.zig").Config;
-pub const context_prefix = " ";
-
+/// Legacy marked rows and hidden locations remain recognizable without metadata.
+/// Visible context locations are flush left and use Row.kind instead.
pub fn isContextLine(line: []const u8) bool {
- return std.mem.startsWith(u8, line, context_prefix) or std.mem.startsWith(u8, line, "| ");
+ return std.mem.startsWith(u8, line, " ") or std.mem.startsWith(u8, line, "| ");
}
pub const Row = struct {
@@ -226,7 +226,6 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us
for (pending.items, 0..) |row, index| {
const before = out.written().len;
const context = row.original == null;
- if (context) try out.writer.writeAll(context_prefix);
try out.writer.writeAll(row.label);
const location_end = if (row.hidden) 0 else out.written().len - before;
if (row.depth > 0) {
@@ -252,7 +251,6 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us
fn labelWidth(row: Pending) usize {
return pardes.panes.File.displayWidth(row.label) +
- @as(usize, if (row.original == null) context_prefix.len else 0) +
@as(usize, if (row.depth > 0) row.depth + 1 else 0);
}
diff --git a/src/panes.zig b/src/panes.zig
index e21b1dc4..09225068 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -1095,7 +1095,7 @@ 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) != locations.isContextLine(line) or
+ (row.kind == .match and row.location_end == 0) 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))
@@ -2442,13 +2442,15 @@ pub const Output = struct {
return mapped;
}
- pub fn nextResult(content: []const u8, path: []const u8, at: look.Spot) usize {
+ pub fn nextResult(content: []const u8, rows: []const locations.Row, path: []const u8, at: look.Spot) usize {
const current: Location = .{ .path = path, .at = at, .end = 0 };
var lines = std.mem.splitScalar(u8, content, '\n');
var first: ?usize = null;
var row: usize = 0;
while (lines.next()) |line| : (row += 1) {
- if (locations.isContextLine(line)) continue;
+ if (row < rows.len) {
+ if (rows[row].kind != .match) continue;
+ } else if (locations.isContextLine(line)) continue;
const target = location(line);
if (target.at.line == 0) continue;
if (first == null) first = row;
diff --git a/src/pardes.zig b/src/pardes.zig
index 51c9c3db..40312770 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -9551,7 +9551,7 @@ pub const Pardes = struct {
if (panes.Output.traits(from).jumps) {
const result = p.panes[pane.search_pane orelse return] orelse return;
const file = pane.file orelse return;
- const row = panes.Output.nextResult(result.file.?.content, lsp.rel(dir, file.path), .{
+ const row = panes.Output.nextResult(result.file.?.content, result.file.?.location_rows, lsp.rel(dir, file.path), .{
.line = @as(usize, @intCast(@max(0, w.row))) + 1,
.col = @as(usize, @intCast(@max(0, w.col))) + 1,
});