diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-14 17:13:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-14 17:13:28 +0800 |
commit | f0fd80ee70928ba27775c0fe40de30c7b936bdb0 (patch) | |
tree | 34d5ddd8c3edbdc2725a99b37543bcc268e4999c /script/workspace/workspace.lua | |
parent | 826175b57368d6daace55cec051aba2aba8ab019 (diff) | |
download | lua-language-server-f0fd80ee70928ba27775c0fe40de30c7b936bdb0.zip |
fix loading workspace may hang
Diffstat (limited to 'script/workspace/workspace.lua')
-rw-r--r-- | script/workspace/workspace.lua | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index fcfde027..e69c6d76 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -320,15 +320,28 @@ function m.awaitPreload() library.matcher:scan(library.path, libraryLoader) end - await.call(function () - for _, loader in ipairs(progressData.loaders) do - loader() - await.delay() + local isLoadingFiles = false + local function loadSomeFiles() + if isLoadingFiles then + return end - end) + await.call(function () + isLoadingFiles = true + while true do + local loader = table.remove(progressData.loaders) + if not loader then + break + end + loader() + await.delay() + end + isLoadingFiles = false + end) + end log.info(('Found %d files.'):format(progressData.max)) while true do + loadSomeFiles() log.info(('Loaded %d/%d files'):format(progressData.read, progressData.max)) progressData:update() if progressData.read >= progressData.max then |