From f02c320a8498c7cf22ef090a28f8d08731308f3d Mon Sep 17 00:00:00 2001 From: bhagwan Date: Thu, 20 Jan 2022 12:55:21 -0800 Subject: [PATCH] bugfix: vim.ui.select code_actions on multiple files (closes #319) --- lua/fzf-lua/providers/ui_select.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/fzf-lua/providers/ui_select.lua b/lua/fzf-lua/providers/ui_select.lua index 6e696b0..bc65e3c 100644 --- a/lua/fzf-lua/providers/ui_select.lua +++ b/lua/fzf-lua/providers/ui_select.lua @@ -76,11 +76,14 @@ M.ui_select = function(items, opts, on_choice) ['--preview-window'] = 'hidden:right:0', } + -- save items so we can access them from the action + _opts.items = items + _opts.actions = vim.tbl_deep_extend("keep", _opts.actions or {}, { - ["default"] = function(selected, _) + ["default"] = function(selected, o) local idx = selected and tonumber(selected[1]:match("^(%d+).")) or nil - on_choice(idx and items[idx] or nil, idx) + on_choice(idx and o.items[idx] or nil, idx) end }) @@ -95,7 +98,7 @@ M.ui_select = function(items, opts, on_choice) return end - actions.act(_opts.actions, selected) + actions.act(_opts.actions, selected, _opts) end)()