summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-19 14:22:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-19 14:22:47 +0800
commitba49cf4de25ab089b5c5d9cf9652decdc5d6a400 (patch)
tree48e7ee92babb793bfbb37a1210a09a92fc6a90c6
parent8ddd562e75b08c82db333a43dbcbc35c9d5e6d49 (diff)
downloadlua-language-server-ba49cf4de25ab089b5c5d9cf9652decdc5d6a400.zip
过滤重复的
-rw-r--r--server/src/matcher/completion.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/src/matcher/completion.lua b/server/src/matcher/completion.lua
index bade05e1..5d9c99f0 100644
--- a/server/src/matcher/completion.lua
+++ b/server/src/matcher/completion.lua
@@ -149,8 +149,13 @@ return function (vm, pos)
return nil
end
local list = {}
+ local mark = {}
if result.type == 'local' then
searchLocals(vm, pos, result.key, function (loc)
+ if mark[loc.key] then
+ return
+ end
+ mark[loc.key] = true
list[#list+1] = {
label = loc.key,
kind = getValueKind(loc.value, CompletionItemKind.Variable),
@@ -159,6 +164,10 @@ return function (vm, pos)
end)
-- 也尝试搜索全局变量
searchFields(result.key, vm.results.locals[1], function (field)
+ if mark[field.key] then
+ return
+ end
+ mark[field.key] = true
list[#list+1] = {
label = field.key,
kind = getValueKind(field.value, CompletionItemKind.Field),
@@ -169,6 +178,10 @@ return function (vm, pos)
if result.parent.value and result.parent.value.ENV == true then
-- 全局变量也搜索是不是local
searchLocals(vm, pos, result.key, function (loc)
+ if mark[loc.key] then
+ return
+ end
+ mark[loc.key] = true
list[#list+1] = {
label = loc.key,
kind = getValueKind(loc.value, CompletionItemKind.Variable),
@@ -177,6 +190,10 @@ return function (vm, pos)
end)
end
searchFields(result.key, result.parent, function (field)
+ if mark[field.key] then
+ return
+ end
+ mark[field.key] = true
list[#list+1] = {
label = field.key,
kind = getValueKind(field.value, CompletionItemKind.Field),