mirror of https://github.com/folke/lazy.nvim.git
perf: fast return for Util.ls when file found
This commit is contained in:
parent
28af1e1ac3
commit
073b5e3caa
|
@ -108,7 +108,7 @@ end
|
||||||
|
|
||||||
---@alias FileType "file"|"directory"|"link"
|
---@alias FileType "file"|"directory"|"link"
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param fn fun(path: string, name:string, type:FileType)
|
---@param fn fun(path: string, name:string, type:FileType):boolean?
|
||||||
function M.ls(path, fn)
|
function M.ls(path, fn)
|
||||||
local handle = vim.loop.fs_scandir(path)
|
local handle = vim.loop.fs_scandir(path)
|
||||||
while handle do
|
while handle do
|
||||||
|
@ -116,7 +116,9 @@ function M.ls(path, fn)
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
fn(path .. "/" .. name, name, t)
|
if fn(path .. "/" .. name, name, t) == false then
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue