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) ~= ''
|
return vim.fn.globpath(dir, glob_pattern, false, false, false) ~= ''
|
||||||
end
|
end
|
||||||
|
|
||||||
---return iterator starting from cwd and going upwards until the project
|
local all_folders_till_root = nil
|
||||||
---root is found by looking for the .git folder.
|
do
|
||||||
---@return fun(): string?
|
|
||||||
local function all_folders_till_root()
|
|
||||||
local cwd = vim.fn.getcwd()
|
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
|
for dir in vim.fs.parents(cwd) do
|
||||||
table.insert(folders, dir)
|
table.insert(folders, dir)
|
||||||
end
|
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
|
local curr = 0
|
||||||
return function()
|
return function()
|
||||||
curr = curr + 1
|
curr = curr + 1
|
||||||
@@ -377,6 +380,7 @@ do
|
|||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---@param glob_pattern string
|
---@param glob_pattern string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user