Skip to content

Commit

Permalink
fix #381 more correct caching
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Feb 8, 2021
1 parent 837f8ab commit 3664077
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# changelog

## 1.14.3
* `FIX` [#381](https://github.com/sumneko/lua-language-server/issues/381)

## 1.14.2
`2021-2-4`
* `FIX` [#356](https://github.com/sumneko/lua-language-server/issues/356)
Expand Down
39 changes: 24 additions & 15 deletions script/parser/guide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ function m.status(parentStatus, interface, deep)
local status = {
share = parentStatus and parentStatus.share or {
count = 0,
cacheLock = {},
},
depth = parentStatus and (parentStatus.depth + 1) or 0,
searchDeep= parentStatus and parentStatus.searchDeep or deep or -999,
Expand Down Expand Up @@ -2882,6 +2883,7 @@ end
--end

function m.getRefCache(status, obj, mode)
local isDeep = status.deep
local globalCache = status.interface.cache and status.interface.cache() or {}
if m.isGlobal(obj) then
obj = m.getKeyName(obj)
Expand All @@ -2893,29 +2895,36 @@ function m.getRefCache(status, obj, mode)
if sourceCache then
return sourceCache
end
sourceCache = {}
globalCache[mode][obj] = sourceCache
if not status.share.cacheLock[mode] then
status.share.cacheLock[mode] = {}
end
if status.share.cacheLock[mode][obj] then
return {}
end
status.share.cacheLock[mode][obj] = {}
return nil, function ()
if status.hasGenericResult then
globalCache[mode][obj] = nil
status.share.cacheLock[mode][obj] = nil
return
end
sourceCache = {}
local results = status.results
for i = 1, #results do
sourceCache[i] = results[i]
end
--if mode == 'ref'
--or mode == 'def' then
-- for i = 1, #results do
-- local res = results[i]
-- if not globalCache[mode][res] then
-- cache[mode][res] = sourceCache
-- if isDeep then
-- globalCache[mode][res] = sourceCache
-- end
-- end
-- end
--end
globalCache[mode][obj] = sourceCache
if not isDeep then
return
end
if mode == 'ref'
or mode == 'def' then
for i = 1, #results do
local res = results[i]
if not globalCache[mode][res] then
globalCache[mode][res] = sourceCache
end
end
end
end
end

Expand Down

0 comments on commit 3664077

Please sign in to comment.