Revert "fix(file_selector): make sure to flatten selected_paths if picker yie…" (#1172)

This commit is contained in:
yetone 2025-02-03 22:01:15 +08:00 committed by GitHub
parent 8536d102be
commit ec3593aac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 9 deletions

View File

@ -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,

View File

@ -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