summaryrefslogtreecommitdiff
path: root/core/Query.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Query.zig')
-rw-r--r--core/Query.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/Query.zig b/core/Query.zig
index 2ffcfd3b..f91339ca 100644
--- a/core/Query.zig
+++ b/core/Query.zig
@@ -1079,7 +1079,9 @@ fn writePlacesRows(p: *Pardes, q: *Query, out: *std.ArrayList(u8), rows: *std.Ar
}
const shade: []const u8 = if (f.highlights.len > 0 and ls >= f.highlight_start and le <= f.highlight_start + f.highlights.len) f.highlights[ls - f.highlight_start .. le - f.highlight_start] else &.{};
try q.items.append(p.gpa, .{ .kind = .hit, .serial = tp.serial, .hit = i, .n = n });
- try writeHitRow(p, out, rows, &sh, width, rel, path, line + 1, f.content[ls..le], hits[i].start - ls, @min(hits[i].end, le) - ls, shade);
+ // The file's line number (the `Changes` layer's lines have none: a
+ // hit in one says the line it stands before).
+ try writeHitRow(p, out, rows, &sh, width, rel, path, File.fileRow(f, line) + 1, f.content[ls..le], hits[i].start - ls, @min(hits[i].end, le) - ls, shade);
i += n;
}
}
@@ -1710,7 +1712,8 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void
if (t.at.line == 0 or t.at.line > nlines) continue;
const full = if (t.path.len > 0 and t.path[0] == '/') t.path else std.fmt.bufPrint(&pathbuf, "{s}/{s}", .{ std.mem.trimEnd(u8, dir, "/"), t.path }) catch continue;
if (!std.mem.eql(u8, full, f.path)) continue;
- const ls = File.lineStart(p.gpa, f, t.at.line - 1);
+ // The server's line is the file's (File.bufferRow).
+ const ls = File.lineStart(p.gpa, f, File.bufferRow(f, t.at.line - 1));
const le = std.mem.indexOfScalarPos(u8, f.content, ls, '\n') orelse f.content.len;
const col = @min(t.at.col -| 1, le - ls);
const end = @min(if (t.at.end_col > 0 and t.at.end_line == t.at.line) t.at.end_col else col + 1, le - ls);
@@ -2088,7 +2091,7 @@ pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16)
while (vr < body_h) : (vr += 1) {
const w = pane.wrapAt(p.settings.tab, vr);
const row = w.line;
- if (row == last or row < 1 or w.ghost) continue;
+ if (row == last or row < 1) continue;
last = row;
const i: usize = @intCast(row - 1);
if (i >= q.items.items.len or @as(usize, @intCast(row)) >= f.location_rows.len) continue;