From 12591b4a9b219c06f2340d9bfd6d589777bda09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 27 Jan 2021 18:26:29 +0800 Subject: fix cache of solve --- script/core/completion.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/script/core/completion.lua b/script/core/completion.lua index e44e2227..dfc01391 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -554,7 +554,12 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res end local function checkField(ast, word, start, offset, parent, oop, results) - local refs = vm.getFields(parent, 0) + local refs + if guide.isGlobal(parent) then + refs = vm.getDefFields(parent, 0) + else + refs = vm.getFields(parent, 0) + end checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results) end @@ -1781,13 +1786,13 @@ end local function resolve(id) local item = resolveStack(id) local cache = workspace.getCache 'completion' - if cache.results then + if item and cache.results then for _, res in ipairs(cache.results) do - if res.data and res.data.id == item.data.id then + if res and res.id == id then for k, v in pairs(item) do res[k] = v end - res.data = nil + res.id = nil break end end -- cgit v1.2.3