Skip to content

Commit

Permalink
fix: undo fzf-lua cancel hack, was fixed upstream (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jan 29, 2024
1 parent 0e88293 commit 6f21226
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions lua/dressing/select/fzf_lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,12 @@ M.select = function(config, items, opts, on_choice)
end
-- Defer the callback to allow the mode to fully switch back to normal after the fzf terminal
local deferred_on_choice = function(...)
local cb = on_choice
on_choice = function() end
local args = vim.F.pack_len(...)
vim.defer_fn(function()
cb(vim.F.unpack_len(args))
on_choice(vim.F.unpack_len(args))
end, 10)
end
ui_select.ui_select(items, opts, deferred_on_choice)

-- Because fzf-lua doesn't call the on_choice function if exited (e.g. with <C-c>), we need to
-- add an autocmd ourselves to make sure that happens.
vim.api.nvim_create_autocmd("BufUnload", {
buffer = vim.api.nvim_get_current_buf(),
once = true,
nested = true,
callback = function()
vim.defer_fn(function()
local cb = on_choice
on_choice = function() end
cb()
end, 10)
end,
})
end

return M

0 comments on commit 6f21226

Please sign in to comment.