From 073b5e3caaf6c2b5b69793ed255fe73680d3d6e2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 28 Nov 2022 11:35:47 +0100 Subject: [PATCH] perf: fast return for Util.ls when file found --- lua/lazy/core/util.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index b9418ea..0cda02b 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -108,7 +108,7 @@ end ---@alias FileType "file"|"directory"|"link" ---@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) local handle = vim.loop.fs_scandir(path) while handle do @@ -116,7 +116,9 @@ function M.ls(path, fn) if not name then break end - fn(path .. "/" .. name, name, t) + if fn(path .. "/" .. name, name, t) == false then + break + end end end