diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-22 14:46:29 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-22 14:46:29 +0800 |
commit | 7e10ca9e3f60c5a108ee3d9bccf9c42da3d74c02 (patch) | |
tree | 0f2cb64c98379382483a339f1ac31bc889d057f4 /server-beta/src | |
parent | 6ff3fcc8a106a3429e5bf7dfd4ca6db5a3cc3e1c (diff) | |
download | lua-language-server-7e10ca9e3f60c5a108ee3d9bccf9c42da3d74c02.zip |
修改预读流程
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/pub/pub.lua | 2 | ||||
-rw-r--r-- | server-beta/src/workspace/workspace.lua | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/server-beta/src/pub/pub.lua b/server-beta/src/pub/pub.lua index cf1eb955..f6db6d4f 100644 --- a/server-beta/src/pub/pub.lua +++ b/server-beta/src/pub/pub.lua @@ -132,7 +132,7 @@ function m.task(name, params) end --- 发布同步任务,如果任务进入了队列,会返回执行器 ----|通过 jumpQueue 可以插队 +--- 通过 jumpQueue 可以插队 ---@parma name string ---@param params any ---@param callback function diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua index efe2f1cf..70334134 100644 --- a/server-beta/src/workspace/workspace.lua +++ b/server-beta/src/workspace/workspace.lua @@ -86,6 +86,8 @@ function m.preload() if not m.uri then return end + local max = 0 + local read = 0 log.info('Preload start.') local ignore = m.getIgnoreMatcher() @@ -111,22 +113,21 @@ function m.preload() if not files.isLua(uri) then return end + max = max + 1 pub.syncTask('loadFile', uri, function (text) + read = read + 1 log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #text / 1000.0)) files.setText(uri, text) end) end) + log.info(('Found %d files.'):format(max)) while true do - local count = 0 - for _, file in pairs(files.fileMap) do - if file.compiling then - task.sleep(0.1) - goto CONTINUE - end - count = count + 1 + log.info(('Loaded %d/%d files'):format(read, max)) + if read < max then + task.sleep(0.1) + goto CONTINUE end - log.info(('Preloaded %d files.'):format(count)) break ::CONTINUE:: end |