Skip to content

Commit ed6994d

Browse files
committed
fix(binds): route preview scroll as DIRECT for fzf previewers
Preview scroll actions (preview-half-page-down, preview-page-down, etc.) in keymap.builtin go through the transform handler which calls win.lua functions operating on the neovim preview buffer. With fzf previewers (bat, git status/commits), the preview is in fzf pane so these functions are no-ops and scrolling does nothing. Fix: in classify_bind, when a preview action matches a whitelist of valid fzf preview action names and the previewer is fzf-native, set entry.fzf_action and return DIRECT so fzf processes it natively. Detect fzf previewer via opts.previewer (set for explicit previewer like "bat") or opts.preview (set by providers like git_commits when the preview command is a fzf --preview string). Only when BOTH are nil is the previewer the neovim builtin overlay. Whitelist prevents invalid fzf action names (preview-reset, preview-ts-ctx-*, etc.) from being routed as DIRECT which would cause fzf to error.
1 parent 5f6ea90 commit ed6994d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

lua/fzf-lua/binds.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,39 @@ local function classify_bind(key, entry, opts)
271271
end
272272

273273
-- Builtin action → transform
274+
-- Preview scroll actions with fzf previewer should be DIRECT so fzf
275+
-- can scroll its own preview pane (the neovim-side functions only
276+
-- work for the builtin previewer). Only route actions that are valid
277+
-- fzf action names; neovim-only preview actions (preview-reset,
278+
-- preview-ts-ctx-*, etc.) must stay as TRANSFORM.
274279
if entry.builtin then
280+
if entry.builtin:match("^preview%-") then
281+
local p = opts.previewer
282+
-- Detect fzf previewer when opts.previewer is not yet resolved:
283+
-- opts.previewer is set → check directly (string/function/table = fzf)
284+
-- opts.previewer is nil → check opts.preview (fzf --preview command)
285+
-- if opts.preview is a string → fzf previewer (e.g. git show)
286+
-- if opts.preview is nil → builtin previewer
287+
local is_builtin = (p == nil or p == true
288+
or p == "hidden" or p == "nohidden")
289+
and not opts.preview
290+
-- Whitelist of preview actions valid in fzf
291+
local fzf_preview_action = ({
292+
["preview-up"] = true,
293+
["preview-down"] = true,
294+
["preview-page-up"] = true,
295+
["preview-page-down"] = true,
296+
["preview-half-page-up"] = true,
297+
["preview-half-page-down"] = true,
298+
["preview-top"] = true,
299+
["preview-bottom"] = true,
300+
["focus-preview"] = true,
301+
})[entry.builtin]
302+
if not is_builtin and fzf_preview_action then
303+
entry.fzf_action = entry.builtin
304+
return M.DIRECT
305+
end
306+
end
275307
return M.TRANSFORM
276308
end
277309

0 commit comments

Comments
 (0)