summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/files.lua2
-rw-r--r--script/vm/getGlobals.lua3
3 files changed, 6 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index ce57ea9c..9f5e9816 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,6 +4,7 @@
* `NEW` diagnostic: `duplicate-set-field`
* `NEW` diagnostic: `no-implicit-any`, disabled by default
* `CHG` completion: improve field and table
+* `CHG` cache globals when loading
* `FIX` diagnositc: may open file with wrong uri case
* `FIX` [#406](https://github.com/sumneko/lua-language-server/issues/406)
diff --git a/script/files.lua b/script/files.lua
index 6dab8a01..fb7487bf 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -266,6 +266,7 @@ end
--- 移除所有文件
function m.removeAll()
+ local ws = require 'workspace.workspace'
m.globalVersion = m.globalVersion + 1
await.close('files.version')
m._pairsCache = nil
@@ -278,6 +279,7 @@ function m.removeAll()
m.onWatch('remove', uri)
end
end
+ ws.flushCache()
--m.notifyCache = {}
end
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua
index 0c502ecd..75512a75 100644
--- a/script/vm/getGlobals.lua
+++ b/script/vm/getGlobals.lua
@@ -264,5 +264,8 @@ files.watch(function (ev, uri)
end
end
needUpdateGlobals[uri] = true
+ elseif ev == 'create' then
+ getGlobalsOfFile(uri)
+ getGlobalSetsOfFile(uri)
end
end)