diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-26 11:00:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-26 11:00:11 +0800 |
commit | be30da2d0c9442bc4d7402487d7829d5ab64abc2 (patch) | |
tree | 43266589614382142670b9308bc5279416196175 /script/workspace | |
parent | 4e806aa1f0ba695ae6c5606813029428b472f5ca (diff) | |
download | lua-language-server-be30da2d0c9442bc4d7402487d7829d5ab64abc2.zip |
keep order after waiting ready
Diffstat (limited to 'script/workspace')
-rw-r--r-- | script/workspace/workspace.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index bca6a5ff..019eb363 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -19,6 +19,7 @@ m.type = 'workspace' m.nativeVersion = -1 m.libraryVersion = -1 m.nativeMatcher = nil +m.waitingReady = {} m.requireCache = {} m.cache = {} m.matchOption = { @@ -477,14 +478,21 @@ function m.awaitReload() plugin.init() m.awaitPreload() m.ready = true + local waiting = m.waitingReady + m.waitingReady = {} + for _, waker in ipairs(waiting) do + waker() + end end ---等待工作目录加载完成 function m.awaitReady() - -- TODO maintain order - while not m.ready do - await.sleep(0.1) + if m.isReady() then + return end + await.wait(function (waker) + m.waitingReady[#m.waitingReady+1] = waker + end) end function m.isReady() |