summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-10-17 17:27:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-10-17 17:27:43 +0800
commit279c1ad7b88e464535971143660712fb0ea259ca (patch)
tree6bfebb86d611440f467fa0c736ad025e20402a39 /script/provider
parent12809be7f931ecf606b32b95665d8e3251e0b81f (diff)
downloadlua-language-server-279c1ad7b88e464535971143660712fb0ea259ca.zip
clear node cache after scope diagnosing
#1626
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/diagnostic.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 149e409f..583173f0 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -23,6 +23,7 @@ local vm = require 'vm.vm'
local m = {}
m.cache = {}
m.sleepRest = 0.0
+m.scopeDiagCount = 0
local function concat(t, sep)
if type(t) ~= 'table' then
@@ -466,6 +467,14 @@ local function askForDisable(uri)
end
end
+local function clearMemory()
+ if m.scopeDiagCount > 0 then
+ return
+ end
+ vm.clearNodeCache()
+ collectgarbage()
+end
+
---@async
function m.awaitDiagnosticsScope(suri, callback)
local scp = scope.getScope(suri)
@@ -475,6 +484,11 @@ function m.awaitDiagnosticsScope(suri, callback)
while loading.count() > 0 do
await.sleep(1.0)
end
+ m.scopeDiagCount = m.scopeDiagCount + 1
+ local scopeDiag <close> = util.defer(function ()
+ m.scopeDiagCount = m.scopeDiagCount - 1
+ clearMemory()
+ end)
local clock = os.clock()
local bar <close> = progress.create(suri, lang.script.WORKSPACE_DIAGNOSTIC, 1)
local cancelled