Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/fff/picker_ui/file_renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ local M = {}
--- Render a file item line
--- @param item FileItem File item from Rust
--- @param ctx ListRenderContext Render context with all state
--- @param item_idx number|nil 1-based item index in ctx.items
--- @return string[] Array of line strings (always exactly 1)
function M.render_line(item, ctx)
function M.render_line(item, ctx, item_idx) -- luacheck: ignore item_idx
local icons = require('fff.file_picker.icons')
local lines = {}

Expand Down
10 changes: 7 additions & 3 deletions lua/fff/picker_ui/grep_renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,14 @@ end
--- or 1 line [match] for subsequent matches in the same file.
---@param item FileItem Grep match item
---@param ctx table Render context
---@param item_idx number 1-based item index in ctx.items
---@return string[]
function M.render_line(item, ctx)
local is_new_group = (item.relative_path ~= ctx._grep_last_file)
ctx._grep_last_file = item.relative_path
function M.render_line(item, ctx, item_idx)
-- 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 = (item_idx == ctx.iter_start)
local is_new_group = is_first_visible or (item.relative_path ~= ctx.grep_last_file)
ctx.grep_last_file = item.relative_path

local match_line = render_match_line(item, ctx)

Expand Down
2 changes: 1 addition & 1 deletion lua/fff/picker_ui/list_renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ local function generate_item_lines(ctx)
local item = ctx.items[i]
local item_start_line = #lines + 1

local item_lines = renderer.render_line(item, ctx)
local item_lines = renderer.render_line(item, ctx, i)
vim.list_extend(lines, item_lines)

local item_end_line = #lines
Expand Down
Loading