summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-24 20:19:15 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-24 20:19:15 +0800
commit061c9b03686c7ae8b3dc70d491ff003258b13bf6 (patch)
tree8a845b40528af04fefb51af6e9fd894fd73b8e5e /script
parent07a9279d513fe2a5787bd0b3693b42b4b573e852 (diff)
downloadlua-language-server-061c9b03686c7ae8b3dc70d491ff003258b13bf6.zip
fix
Diffstat (limited to 'script')
-rw-r--r--script/core/completion.lua24
1 files changed, 18 insertions, 6 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index a2eaca4e..fb7b2eb4 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1933,6 +1933,23 @@ local function makeCache(uri, offset, results)
cache.length = #word
end
+local function isValidCache(word, result)
+ if result.kind == define.CompletionItemKind.Text then
+ return false
+ end
+ local match = result.match or result.label
+ if matchKey(word, match) then
+ return true
+ end
+ if result.textEdit then
+ match = result.textEdit.newText:match '[%w_]+'
+ if match and matchKey(word, match) then
+ return true
+ end
+ end
+ return false
+end
+
local function getCache(uri, offset)
local cache = workspace.getCache 'completion'
if not cache.results then
@@ -1952,12 +1969,7 @@ local function getCache(uri, offset)
local results = cache.results
for i = #results, 1, -1 do
local result = results[i]
- local match = result.match or result.label
- if results.enableCommon and result.kind == define.CompletionItemKind.Text then
- results[i] = results[#results]
- results[#results] = nil
- elseif matchKey(word, match)
- or (result.textEdit and matchKey(word, result.textEdit.newText:match '[%w_]*')) then
+ if isValidCache(word, result) then
if result.textEdit then
result.textEdit.finish = result.textEdit.finish + ext
end