From 39611852fd7bbac117e939a26759bb37361f0c90 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Mon, 17 Jul 2023 16:24:00 -0700 Subject: [PATCH] fix: inconsistent mode after selecting with fzf-lua --- lua/dressing/select/fzf_lua.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/dressing/select/fzf_lua.lua b/lua/dressing/select/fzf_lua.lua index 64362d5..041a4c2 100644 --- a/lua/dressing/select/fzf_lua.lua +++ b/lua/dressing/select/fzf_lua.lua @@ -11,7 +11,14 @@ M.select = function(config, items, opts, on_choice) ui_select.register(config, true) ui_select.deregister(nil, true, true) end - return ui_select.ui_select(items, opts, on_choice) + -- Defer the callback to allow the mode to fully switch back to normal after the fzf terminal + local deferred_on_choice = function(...) + local args = vim.F.pack_len(...) + vim.defer_fn(function() + on_choice(vim.F.unpack_len(args)) + end, 1) + end + return ui_select.ui_select(items, opts, deferred_on_choice) end return M