summaryrefslogtreecommitdiff
path: root/src/file_pane.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_pane.zig')
-rw-r--r--src/file_pane.zig19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/file_pane.zig b/src/file_pane.zig
index 5c7f4b77..9b828030 100644
--- a/src/file_pane.zig
+++ b/src/file_pane.zig
@@ -722,10 +722,25 @@ pub fn refreshHighlights(p: *Pardes) void {
// a fidelity gain, and one that cannot reach a file shown from the top
// (scroll 0 clamps the window to exactly what it always was).
const slack: usize = if (f.highlights.len == 0) 0 else pane.rows;
- const start = lineStart(p.gpa, f, f.scroll -| slack);
- const end = @max(start, lineStart(p.gpa, f, f.scroll + pane.rows + SYNTAX_CONTEXT_AFTER_ROWS + slack));
+ // A RESULTS BUFFER IS COLOURED WHOLE, ONCE. Its rows are independent —
+ // each is parsed in isolation against its own grammar — so a window
+ // pass buys no fidelity, only amortisation, and pays for it with a
+ // burst on every scroll that outran the covered range: a fresh parser,
+ // a fresh query cursor and a tree per row, plus the first compile of
+ // any grammar the new rows introduce, all inside `render`. Colouring
+ // the whole buffer when it is FILLED makes the covered-range check
+ // above true forever after, so scrolling one costs nothing at all.
+ // Bounded by what fills them: `look.find_max_hits` caps a grep at 512
+ // rows, and a rendering is never typed into.
+ const whole = pane.colorAlgo() == .locations;
+ const start = if (whole) 0 else lineStart(p.gpa, f, f.scroll -| slack);
+ const end = if (whole)
+ f.content.len
+ else
+ @max(start, lineStart(p.gpa, f, f.scroll + pane.rows + SYNTAX_CONTEXT_AFTER_ROWS + slack));
const new_highlights = (switch (pane.colorAlgo()) {
.diff => syntax.highlightDiff(p.tree_sitter_gpa, f.content, start, end),
+ .locations => syntax.highlightLocations(p.tree_sitter_gpa, f.content, start, end),
else => syntax.highlightFileRange(p.tree_sitter_gpa, f.path, f.content, start, end),
}) catch {
f.syntax_dirty = false;