diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-27 16:24:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-27 16:24:02 +0800 |
commit | 219c802e4e6a67aa9c4a1b4a5bd7886f8181b7c4 (patch) | |
tree | 4acfbd7290555928768f866085c5567499b85f82 /script/vm | |
parent | b436b123d67e1c5aa3945da404109fbeb12bdb53 (diff) | |
download | lua-language-server-219c802e4e6a67aa9c4a1b4a5bd7886f8181b7c4.zip |
improve performance of completion
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/getGlobals.lua | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua index fcaffdf7..22e819f5 100644 --- a/script/vm/getGlobals.lua +++ b/script/vm/getGlobals.lua @@ -1,4 +1,5 @@ local guide = require 'parser.guide' +local await = require "await" ---@type vm local vm = require 'vm.vm' local files = require 'files' @@ -230,11 +231,17 @@ files.watch(function (ev, uri) getGlobalSetsCache['*'] = nil end end - for name in pairs(getGlobalsOfFile(uri)) do - getGlobalCache[name] = nil - end - for name in pairs(getGlobalSetsOfFile(uri)) do - getGlobalSetsCache[name] = nil - end + await.call(function () + local id = 'refreshNewGlobals:' .. uri + await.close(id) + await.setID(id) + await.sleep(1.0) + for name in pairs(getGlobalsOfFile(uri)) do + getGlobalCache[name] = nil + end + for name in pairs(getGlobalSetsOfFile(uri)) do + getGlobalSetsCache[name] = nil + end + end) end end) |