summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-08 14:48:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-08 14:48:24 +0800
commit0c6f72254d1253f12261650b90652465230bdeec (patch)
tree309cf881bd1210df353cd9a4245e4eef86a009fa
parent3664077884752b6eb9f59e0f641a4eea9178e358 (diff)
downloadlua-language-server-0c6f72254d1253f12261650b90652465230bdeec.zip
better cache
-rw-r--r--script/core/completion.lua9
1 files 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