From 59a9b96ccc7c251ec46929667c3decc10ba42dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 24 Dec 2021 14:35:22 +0800 Subject: disable cache in completion --- script/core/completion/completion.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'script/core/completion') diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 472b1118..d98a7c3d 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1966,6 +1966,7 @@ local function isValidCache(word, result) end local function getCache(uri, position) + do return nil end local cache = workspace.getCache 'completion' if not cache.results then return nil @@ -2063,9 +2064,9 @@ local function completion(uri, position, triggerCharacter) return nil end - tracy.ZoneBeginN 'completion #3' - makeCache(uri, position, results) - tracy.ZoneEnd() + --tracy.ZoneBeginN 'completion #3' + --makeCache(uri, position, results) + --tracy.ZoneEnd() return results end -- cgit v1.2.3 From fbf9084fbd5e96eb9bd5854871495423184d507b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 24 Dec 2021 14:54:16 +0800 Subject: fix --- script/core/completion/completion.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'script/core/completion') diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index d98a7c3d..425c8026 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1525,8 +1525,14 @@ local function tryTable(state, position, results) end local function getComment(state, position) + local offset = guide.positionToOffset(state, position) + local symbolOffset = lookBackward.findAnyOffset(state.lua, offset) + if not symbolOffset then + return + end + local symbolPosition = guide.offsetToPosition(state, symbolOffset) for _, comm in ipairs(state.comms) do - if position > comm.start and position <= comm.finish then + if symbolPosition > comm.start and symbolPosition <= comm.finish then return comm end end @@ -1534,8 +1540,14 @@ local function getComment(state, position) end local function getluaDoc(state, position) + local offset = guide.positionToOffset(state, position) + local symbolOffset = lookBackward.findAnyOffset(state.lua, offset) + if not symbolOffset then + return + end + local symbolPosition = guide.offsetToPosition(state, symbolOffset) for _, doc in ipairs(state.ast.docs) do - if position >= doc.start and position <= doc.range then + if symbolPosition >= doc.start and symbolPosition <= doc.range then return doc end end -- cgit v1.2.3