diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-28 21:04:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-28 21:04:07 +0800 |
commit | 1dee813e59166317d993a6010c66e267e69a82c2 (patch) | |
tree | 038c731d4ad82a7de9cfbd4166780d92cf0718a6 /server | |
parent | ec1806e3b65623e2238bfc3bdb5fc53181074462 (diff) | |
download | lua-language-server-1dee813e59166317d993a6010c66e267e69a82c2.zip |
加快主线程循环速度
Diffstat (limited to 'server')
-rw-r--r-- | server/src/method/workspace/executeCommand.lua | 2 | ||||
-rw-r--r-- | server/src/service.lua | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/server/src/method/workspace/executeCommand.lua b/server/src/method/workspace/executeCommand.lua index 0d579848..00ee09a3 100644 --- a/server/src/method/workspace/executeCommand.lua +++ b/server/src/method/workspace/executeCommand.lua @@ -57,7 +57,7 @@ function command.config(lsp, data) fs.create_directories(vscodePath) end - local setting = json.decode(settingBuf, true) or {} + local setting = json.decode(settingBuf or '', true) or {} local key = 'Lua.' .. table.concat(data.key, '.') local attr = setting[key] diff --git a/server/src/service.lua b/server/src/service.lua index 1145b210..7a6acdb9 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -720,6 +720,7 @@ function mt:listen() local clock = os.clock() while true do + local startClock = os.clock() async.onTick() self:onTick() @@ -730,7 +731,13 @@ function mt:listen() io.stderr:write(err) io.stderr:flush() end - thread.sleep(0.001) + + local passedClock = os.clock() - startClock + if passedClock > 0.1 then + thread.sleep(0.0) + else + thread.sleep(0.001) + end end end |