From 6ebba1526bccdb08e94aa386c07acae39261d0e2 Mon Sep 17 00:00:00 2001 From: Herschel Date: Tue, 7 Jan 2025 14:35:24 +0800 Subject: [PATCH] feat(file_selector_fzf): Add multi select for fzf-lua file selector (#1047) --- lua/avante/file_selector.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index e27fda2..6a3a476 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -142,8 +142,14 @@ function FileSelector:fzf_ui(handler) git_icons = false, actions = { ["default"] = function(selected) - local file = fzf_lua.path.entry_to_file(selected[1]) - handler(file.path) + if not selected or #selected == 0 then return close_action() end + local selections = {} + for _, entry in ipairs(selected) do + local file = fzf_lua.path.entry_to_file(entry) + if file and file.path then table.insert(selections, file.path) end + end + + if #selections > 0 then handler(#selections == 1 and selections[1] or selections) end end, ["esc"] = close_action, ["ctrl-c"] = close_action, @@ -200,7 +206,6 @@ function FileSelector:telescope_ui(handler) :find() end ----@type FileSelectorHandler function FileSelector:native_ui(handler) local filepaths = vim .iter(self.file_cache)