summaryrefslogtreecommitdiff
path: root/server-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-22 15:12:12 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-22 15:12:12 +0800
commit917d721acdf86ff69728fae89662019c519ea561 (patch)
tree1a508d8b54e54a2a0f75edb739f57803bb28ff0b /server-beta
parent7ff8068c23a02f9faf45ad34d9385b1dfda4d987 (diff)
downloadlua-language-server-917d721acdf86ff69728fae89662019c519ea561.zip
遍历目录在主线程中完成
Diffstat (limited to 'server-beta')
-rw-r--r--server-beta/src/workspace/workspace.lua15
1 files changed, 6 insertions, 9 deletions
diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua
index 70334134..7f2998be 100644
--- a/server-beta/src/workspace/workspace.lua
+++ b/server-beta/src/workspace/workspace.lua
@@ -92,7 +92,7 @@ function m.preload()
local ignore = m.getIgnoreMatcher()
ignore:setInterface('type', function (path)
- if pub.task('isDirectory', furi.encode(m.path .. '/' .. path)) then
+ if fs.is_directory(fs.path(m.path .. '/' .. path)) then
return 'directory'
else
return 'file'
@@ -100,10 +100,9 @@ function m.preload()
end)
ignore:setInterface('list', function (path)
- local uris = pub.task('listDirectory', furi.encode(m.path .. '/' .. path))
local paths = {}
- for i, uri in ipairs(uris) do
- paths[i] = furi.decode(uri)
+ for fullpath in fs.path(m.path .. '/' .. path):list_directory() do
+ paths[#paths+1] = fullpath:string()
end
return paths
end)
@@ -124,12 +123,10 @@ function m.preload()
log.info(('Found %d files.'):format(max))
while true do
log.info(('Loaded %d/%d files'):format(read, max))
- if read < max then
- task.sleep(0.1)
- goto CONTINUE
+ if read >= max then
+ break
end
- break
- ::CONTINUE::
+ task.sleep(0.1)
end
log.info('Preload finish.')