slight optimization
reuse the same folder array. just keep it in memory forever
This commit is contained in:
@@ -358,15 +358,18 @@ do
|
||||
return vim.fn.globpath(dir, glob_pattern, false, false, false) ~= ''
|
||||
end
|
||||
|
||||
---return iterator starting from cwd and going upwards until the project
|
||||
---root is found by looking for the .git folder.
|
||||
---@return fun(): string?
|
||||
local function all_folders_till_root()
|
||||
local all_folders_till_root = nil
|
||||
do
|
||||
local cwd = vim.fn.getcwd()
|
||||
local folders = {cwd}
|
||||
local folders = {cwd} -- array of all folders from cwd to root
|
||||
for dir in vim.fs.parents(cwd) do
|
||||
table.insert(folders, dir)
|
||||
end
|
||||
|
||||
---return iterator starting from cwd and going upwards until the project
|
||||
---root is found by looking for the .git folder.
|
||||
---@return fun(): string?
|
||||
all_folders_till_root = function()
|
||||
local curr = 0
|
||||
return function()
|
||||
curr = curr + 1
|
||||
@@ -377,6 +380,7 @@ do
|
||||
return f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param glob_pattern string
|
||||
---@return boolean
|
||||
|
||||
Reference in New Issue
Block a user