Skip to content

fix(finder): handle abort in fzf-lua integration - #2001

Open
aliaksandr-trush wants to merge 1 commit into
NeogitOrg:masterfrom
aliaksandr-trush:fix_fzf_lua_finder
Open

fix(finder): handle abort in fzf-lua integration#2001
aliaksandr-trush wants to merge 1 commit into
NeogitOrg:masterfrom
aliaksandr-trush:fix_fzf_lua_finder

Conversation

@aliaksandr-trush

Copy link
Copy Markdown

Finder:find documents that on_select is invoked with the selected item or nil if aborted. Every integration honors this except fzf_lua: the esc/ctrl-c/ctrl-q actions only fire when fzf prints one of those keys back, and when the fzf process is instead terminated (window closed, job killed) fzf-lua dispatches no action at all.

Through find_async = a.wrap(Finder.find, 2), callers using open_async (e.g. bb -> checkout_branch_revision) coroutine.yield waiting for on_select to resume them. When on_select never runs, the coroutine is suspended forever holding the popup lock (permits == 0) and the picker appears dead until Neovim is restarted.

Wire fzf-lua's winopts.on_close to an abort handler so a picker close still completes the finder via on_select(nil). on_close runs before the selected action is dispatched, so it is deferred to the next event loop tick; the completed guard (mirroring mini_pick_choose and snacks_confirm) ensures on_select runs exactly once.

`Finder:find` documents that `on_select` is invoked with the selected item
or `nil` if aborted. Every integration honors this except `fzf_lua`: the
`esc`/`ctrl-c`/`ctrl-q` actions only fire when fzf prints one of those keys
back, and when the fzf process is instead terminated (window closed, job
killed) fzf-lua dispatches no action at all.

Through `find_async = a.wrap(Finder.find, 2)`, callers using `open_async`
(e.g. `bb` -> `checkout_branch_revision`) `coroutine.yield` waiting for
`on_select` to resume them. When `on_select` never runs, the coroutine is
suspended forever holding the popup lock (`permits == 0`) and the picker
appears dead until Neovim is restarted.

Wire fzf-lua's `winopts.on_close` to an abort handler so a picker close
still completes the finder via `on_select(nil)`. `on_close` runs before the
selected action is dispatched, so it is deferred to the next event loop
tick; the `completed` guard (mirroring `mini_pick_choose` and
`snacks_confirm`) ensures `on_select` runs exactly once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant