diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-31 01:37:10 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-31 01:37:10 +0800 |
commit | ffeed6eacdb8ad69c7b5f2294c0c12b402de89d5 (patch) | |
tree | 4986b21179e4f3a1e28a4e5fd4b398bf9facefce /script/vm | |
parent | 4758a1ed42e23d4d8e121f0d5cb5bec0801fa583 (diff) | |
download | lua-language-server-ffeed6eacdb8ad69c7b5f2294c0c12b402de89d5.zip |
safe pairs
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/getGlobals.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua index e1fd0e7a..842db4c3 100644 --- a/script/vm/getGlobals.lua +++ b/script/vm/getGlobals.lua @@ -194,14 +194,20 @@ local function checkNeedUpdate() local getGlobalCache = ws.getCache 'getGlobals' local getGlobalSetsCache = ws.getCache 'getGlobalSets' local needUpdateGlobals = ws.getCache 'needUpdateGlobals' + local uris = {} for uri in pairs(needUpdateGlobals) do - needUpdateGlobals[uri] = nil - if files.exists(uri) then - for name in pairs(getGlobalsOfFile(uri)) do - getGlobalCache[name] = nil - end - for name in pairs(getGlobalSetsOfFile(uri)) do - getGlobalSetsCache[name] = nil + uris[#uris+1] = uri + end + for _, uri in ipairs(uris) do + if needUpdateGlobals[uri] then + needUpdateGlobals[uri] = nil + if files.exists(uri) then + 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 |