fix: missing filename header when scrolling up in live_grep (#470)#496
Conversation
1165af6 to
4fa96f1
Compare
|
@gustav-fff rebase and retest thsi |
First item after pagination treated as continuation of previous file group, resulting in no header. Fix: always render header for first visible item (iter_start) in the render pass. Refs #470
4fa96f1 to
3a465e8
Compare
|
[triage-bot] DIRECTED: rebased onto main (3a465e8). Conflict in CI will retest. Honk-Honk 🪿 |
| local is_new_group = (item.relative_path ~= ctx._grep_last_file) | ||
| -- First rendered item in this pass always gets header — fixes missing header | ||
| -- when paginating backward in multi-page grep results (ctx is fresh per render). | ||
| local is_first_visible = not ctx._grep_first_rendered |
There was a problem hiding this comment.
why this is unused?
keep this used and add this to the lua defintion params
cc @gustav-fff work on this PR and babysit it
There was a problem hiding this comment.
[triage-bot] DIRECTED: pushed fbce94b.
render_line(item, ctx, item_idx) — list_renderer now passes i consistently with apply_highlights. First-visible check is item_idx == ctx.iter_start, no stateful flag. file_renderer.render_line signature updated to accept the optional param.
Honk-Honk 🪿
Replace _grep_first_rendered flag with item_idx == ctx.iter_start check. list_renderer now passes item_idx to render_line consistently with apply_highlights signature.
|
@gustav-fff _grep_last_file -> rename this to gre_last_file as it is now used AND ACUTALLY WAIT FOR CI TO PASS BEFORE LEAVING THIS PR |
Field is part of the render context API now, drop the underscore prefix.
|
[triage-bot] DIRECTED: pushed 369a6a6 — renamed CI kicked off, currently pending across the build matrix. Will not consider this done until it goes green. Honk-Honk 🪿 |
|
@gustav-fff fix the luacheck lint |
|
[triage-bot] DIRECTED: pushed ab5301c.
Honk-Honk 🪿 |
Closes #470
Root cause
lua/fff/grep/grep_renderer.lua:207— file grouping logic usesctx._grep_last_fileto track consecutive matches from same file. This state resets per render (context is fresh each call). When user scrolls up past page boundary and new results load, first item in new page compared againstnil→ looks like different file but no way to distinguish "truly new file" from "first visible item after pagination". Result: no header rendered even though file might be same as last item on previous page.Fix
Always render header for first visible item (
ctx.iter_start). Ensures filename always shown at top of viewport regardless of pagination state. Trade-off: duplicate header if scrolling within same file, but matches user expectation — "I see a match, I need to know which file".Steps to reproduce
Requires large repo with multi-file grep results spanning multiple pages:
```sh
cd # e.g. linux kernel, chromium, large monorepo
nvim
:lua require('fff').search('function') -- common keyword with many hits
Navigate down past first page boundary (e.g. j × 100)
Navigate back up past page boundary (e.g. k × 100)
Observe: top filename header missing on scrolled-to page
```
Expected: filename header visible for topmost match.
Actual (pre-fix): filename missing, only
:line:coland content shown.How verified
Code inspection: change targets exact root cause. Logic:
is_first_visible = (item_idx == ctx.iter_start)ensures first rendered item always gets header. Checked signature match withfile_renderer.render_line(third param already present but unused). Ran formatter (stylua passed).Automated triage via gustav-fff bot.