From ec3593aac6e6e2c708d61518d4095eb1ab11a504 Mon Sep 17 00:00:00 2001 From: yetone <yetoneful@gmail.com> Date: Mon, 3 Feb 2025 22:01:15 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(file=5Fselector):=20make=20sure?= =?UTF-8?q?=20to=20flatten=20selected=5Fpaths=20if=20picker=20yie=E2=80=A6?= =?UTF-8?q?"=20(#1172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/avante/config.lua | 2 -- lua/avante/file_selector.lua | 10 +++------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 78c422b..163dc43 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -255,8 +255,6 @@ M._defaults = { provider = "native", -- Options override for custom providers provider_opts = {}, - --- @type fun(selected_paths: string[] | string | nil): nil - handler = nil, }, suggestion = { debounce = 600, diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index f70a329..4767b26 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -30,16 +30,13 @@ function FileSelector:process_directory(absolute_path, project_root) self:emit("update") end ----@param selected_paths string | string[] | nil +---@param selected_paths string[] | nil ---@return nil function FileSelector:handle_path_selection(selected_paths) if not selected_paths then return end local project_root = Utils.get_project_root() - -- Convert single string to array if needed - local paths = type(selected_paths) == "string" and { selected_paths } or selected_paths - - for _, selected_path in ipairs(paths) do + for _, selected_path in ipairs(selected_paths) do local absolute_path = Path:new(project_root):joinpath(selected_path):absolute() local stat = vim.loop.fs_stat(absolute_path) @@ -316,8 +313,7 @@ end ---@return nil function FileSelector:show_select_ui() - local handler = Config.file_selector.handler - if handler == nil then handler = function(selected_paths) self:handle_path_selection(selected_paths) end end + local function handler(selected_paths) self:handle_path_selection(selected_paths) end vim.schedule(function() if Config.file_selector.provider == "native" then