Skip to content

Commit

Permalink
fix(ui_select): abort doesn't call on_choice (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Jan 27, 2024
1 parent c6b2ce7 commit 5474df3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lua/fzf-lua/providers/ui_select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ end
M.accept_item = function(selected, o)
local idx = selected and tonumber(selected[1]:match("^(%d+)%.")) or nil
o._on_choice(idx and o._items[idx] or nil, idx)
o._on_choice_called = true
end

M.ui_select = function(items, ui_opts, on_choice)
Expand Down Expand Up @@ -116,9 +117,21 @@ M.ui_select = function(items, ui_opts, on_choice)
config.set_action_helpstr(opts.actions["default"], nil)

if not selected then
-- with `actions.dummy_abort` this doesn't get called anymore
-- as the action is configured as a valid fzf "accept" (thus
-- `selected` isn't empty), see below comment for mor info
on_choice(nil, nil)
else
o._on_choice_called = nil
actions.act(o.actions, selected, o)
if not o._on_choice_called then
-- see comment above, `on_choice` wasn't called, either
-- "dummy_abort" (ctrl-c/esc) or (unlikely) the user setup
-- additional binds that aren't for "accept". Not calling
-- with nil (no action) can cause issues, for example with
-- dressing.nvim (#1014)
on_choice(nil, nil)
end
end

if opts.post_action_cb then
Expand Down

0 comments on commit 5474df3

Please sign in to comment.