From 0c6f72254d1253f12261650b90652465230bdeec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 8 Feb 2021 14:48:24 +0800 Subject: better cache --- script/core/completion.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/script/core/completion.lua b/script/core/completion.lua index 33c8f70e..97e83f00 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -1707,7 +1707,7 @@ local function makeCache(uri, offset, results) return end cache.results = results - cache.offset = offset + cache.start = offset - #word + 1 cache.word = word:lower() end @@ -1717,11 +1717,8 @@ local function getCache(uri, offset) return nil end local text = files.getText(uri) - local word = findWord(text, offset) - if not word then - return nil - end - if word:sub(1, #cache.word):lower() ~= cache.word then + local word = text:sub(cache.start, offset) + if word:lower() ~= cache.word then return nil end -- cgit v1.2.3