summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-08 16:29:07 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-08 16:29:07 +0800
commitc1eb1dfc323c20b2bfce9156b5dcd2866aeb8732 (patch)
tree4ca953bcae44edb5e94dc8019da3772e7ce2b8ac /script/core
parent9d2a2e1abf9d1c79d5538bdbf13a8f249d5176a4 (diff)
downloadlua-language-server-c1eb1dfc323c20b2bfce9156b5dcd2866aeb8732.zip
Revert "better cache"
This reverts commit 0c6f72254d1253f12261650b90652465230bdeec.
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index d2f761c1..a8500b09 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.start = offset - #word + 1
+ cache.offset = offset
cache.word = word:lower()
end
@@ -1717,8 +1717,11 @@ local function getCache(uri, offset)
return nil
end
local text = files.getText(uri)
- local word = text:sub(cache.start, offset)
- if word:lower() ~= cache.word then
+ local word = findWord(text, offset)
+ if not word then
+ return nil
+ end
+ if word:sub(1, #cache.word):lower() ~= cache.word then
return nil
end