feat: use scan_directory util (#2121)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
local Utils = require("avante.utils")
|
local Utils = require("avante.utils")
|
||||||
local scan = require("plenary.scandir")
|
|
||||||
local Config = require("avante.config")
|
local Config = require("avante.config")
|
||||||
local Selector = require("avante.ui.selector")
|
local Selector = require("avante.ui.selector")
|
||||||
|
|
||||||
@@ -19,12 +18,7 @@ local function has_scheme(path) return path:find("^%w+://") ~= nil end
|
|||||||
|
|
||||||
function FileSelector:process_directory(absolute_path, project_root)
|
function FileSelector:process_directory(absolute_path, project_root)
|
||||||
if absolute_path:sub(-1) == Utils.path_sep then absolute_path = absolute_path:sub(1, -2) end
|
if absolute_path:sub(-1) == Utils.path_sep then absolute_path = absolute_path:sub(1, -2) end
|
||||||
local files = scan.scan_dir(absolute_path, {
|
local files = Utils.scan_directory({ directory = absolute_path, add_dirs = false })
|
||||||
hidden = false,
|
|
||||||
depth = math.huge,
|
|
||||||
add_dirs = false,
|
|
||||||
respect_gitignore = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local rel_path = Utils.make_relative_path(file, project_root)
|
local rel_path = Utils.make_relative_path(file, project_root)
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ function M.scan_directory(options)
|
|||||||
end
|
end
|
||||||
cmd_supports_max_depth = false
|
cmd_supports_max_depth = false
|
||||||
else
|
else
|
||||||
M.error("No search command found")
|
M.error("No search command found, please install fd or fdfind or rg")
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user