diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-19 14:22:47 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-19 14:22:47 +0800 |
commit | ba49cf4de25ab089b5c5d9cf9652decdc5d6a400 (patch) | |
tree | 48e7ee92babb793bfbb37a1210a09a92fc6a90c6 | |
parent | 8ddd562e75b08c82db333a43dbcbc35c9d5e6d49 (diff) | |
download | lua-language-server-ba49cf4de25ab089b5c5d9cf9652decdc5d6a400.zip |
过滤重复的
-rw-r--r-- | server/src/matcher/completion.lua | 17 |
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), |