Skip to content

Commit 3664077

Browse files
committed
fix #381 more correct caching
1 parent 837f8ab commit 3664077

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# changelog
22

3+
## 1.14.3
4+
* `FIX` [#381](https://github.com./sumneko/lua-language-server/issues/381)
5+
36
## 1.14.2
47
`2021-2-4`
58
* `FIX` [#356](https://github.com./sumneko/lua-language-server/issues/356)

script/parser/guide.lua

+24-15
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,7 @@ function m.status(parentStatus, interface, deep)
12341234
local status = {
12351235
share = parentStatus and parentStatus.share or {
12361236
count = 0,
1237+
cacheLock = {},
12371238
},
12381239
depth = parentStatus and (parentStatus.depth + 1) or 0,
12391240
searchDeep= parentStatus and parentStatus.searchDeep or deep or -999,
@@ -2882,6 +2883,7 @@ end
28822883
--end
28832884

28842885
function m.getRefCache(status, obj, mode)
2886+
local isDeep = status.deep
28852887
local globalCache = status.interface.cache and status.interface.cache() or {}
28862888
if m.isGlobal(obj) then
28872889
obj = m.getKeyName(obj)
@@ -2893,29 +2895,36 @@ function m.getRefCache(status, obj, mode)
28932895
if sourceCache then
28942896
return sourceCache
28952897
end
2896-
sourceCache = {}
2897-
globalCache[mode][obj] = sourceCache
2898+
if not status.share.cacheLock[mode] then
2899+
status.share.cacheLock[mode] = {}
2900+
end
2901+
if status.share.cacheLock[mode][obj] then
2902+
return {}
2903+
end
2904+
status.share.cacheLock[mode][obj] = {}
28982905
return nil, function ()
28992906
if status.hasGenericResult then
2900-
globalCache[mode][obj] = nil
2907+
status.share.cacheLock[mode][obj] = nil
29012908
return
29022909
end
2910+
sourceCache = {}
29032911
local results = status.results
29042912
for i = 1, #results do
29052913
sourceCache[i] = results[i]
29062914
end
2907-
--if mode == 'ref'
2908-
--or mode == 'def' then
2909-
-- for i = 1, #results do
2910-
-- local res = results[i]
2911-
-- if not globalCache[mode][res] then
2912-
-- cache[mode][res] = sourceCache
2913-
-- if isDeep then
2914-
-- globalCache[mode][res] = sourceCache
2915-
-- end
2916-
-- end
2917-
-- end
2918-
--end
2915+
globalCache[mode][obj] = sourceCache
2916+
if not isDeep then
2917+
return
2918+
end
2919+
if mode == 'ref'
2920+
or mode == 'def' then
2921+
for i = 1, #results do
2922+
local res = results[i]
2923+
if not globalCache[mode][res] then
2924+
globalCache[mode][res] = sourceCache
2925+
end
2926+
end
2927+
end
29192928
end
29202929
end
29212930

0 commit comments

Comments
 (0)