summaryrefslogtreecommitdiff
path: root/script/workspace
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-02-04 16:08:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-02-04 16:08:54 +0800
commit4504ee2ff574ab378ecf70f0bbfc5f664012ef02 (patch)
treea6f443aa3ad6ae58a791f8dc494ac187db4cc930 /script/workspace
parent9ba615e2af45cfe98d59612eb058f78372aa2966 (diff)
downloadlua-language-server-4504ee2ff574ab378ecf70f0bbfc5f664012ef02.zip
improve peformance for scanning files
#1872
Diffstat (limited to 'script/workspace')
-rw-r--r--script/workspace/workspace.lua31
1 files changed, 25 insertions, 6 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index ad306beb..9d701167 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -84,26 +84,45 @@ function m.getRootUri(uri)
end
local globInteferFace = {
- type = function (path)
+ type = function (path, data)
+ if data[path] then
+ return data[path]
+ end
local result
pcall(function ()
- if fs.is_directory(path) then
+ if fs.is_directory(fs.path(path)) then
result = 'directory'
+ data[path] = 'directory'
else
result = 'file'
+ data[path] = 'file'
end
end)
return result
end,
- list = function (path)
+ list = function (path, data)
+ if data[path] == 'file' then
+ return nil
+ end
local fullPath = fs.path(path)
if not fs.is_directory(fullPath) then
+ data[path] = 'file'
return nil
end
+ data[path] = true
local paths = {}
pcall(function ()
- for fullpath in fs.pairs(fullPath) do
- paths[#paths+1] = fullpath:string()
+ for fullpath, status in fs.pairs(fullPath) do
+ local pathString = fullpath:string()
+ paths[#paths+1] = pathString
+ local st = status:type()
+ if st == 'directory'
+ or st == 'symlink'
+ or st == 'junction' then
+ data[pathString] = 'directory'
+ else
+ data[pathString] = 'file'
+ end
end
end)
return paths
@@ -225,7 +244,7 @@ function m.getLibraryMatchers(scp)
end
scp:set('libraryMatcher', matchers)
- log.debug('library matcher:', inspect(matchers))
+ --log.debug('library matcher:', inspect(matchers))
return matchers
end