summaryrefslogtreecommitdiff
path: root/script-beta/core/completion.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-18 16:17:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-18 16:17:26 +0800
commit9a573f53de4a041cca4125b5e54cb27c2f097a9d (patch)
tree5940ecf97f19f3c7b40cf163f168ffa9594e0689 /script-beta/core/completion.lua
parentf91735b40a6829df71547151ee72f42f4a9ed2fc (diff)
downloadlua-language-server-9a573f53de4a041cca4125b5e54cb27c2f097a9d.zip
更新自动完成
Diffstat (limited to 'script-beta/core/completion.lua')
-rw-r--r--script-beta/core/completion.lua24
1 files changed, 11 insertions, 13 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index dc05d0a1..fe007368 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -167,7 +167,7 @@ end
local function buildFunction(results, source, oop, data)
local snipType = config.config.completion.callSnippet
if snipType == 'Disable' or snipType == 'Both' then
- results[data.label] = data
+ results[#results+1] = data
end
if snipType == 'Both' or snipType == 'Replace' then
local snipData = util.deepCopy(data)
@@ -181,7 +181,7 @@ local function buildFunction(results, source, oop, data)
description = buildDesc(source),
}
end)
- results[snipData.label] = snipData
+ results[#results+1] = snipData
end
end
@@ -229,7 +229,7 @@ local function checkLocal(ast, word, offset, results)
end
end
-local function checkFieldThen(src, results, word, start, parent, oop, results)
+local function checkFieldThen(src, word, start, parent, oop, results, used)
local key = vm.getKeyName(src)
if not key or key:sub(1, 1) ~= 's' then
return
@@ -237,6 +237,10 @@ local function checkFieldThen(src, results, word, start, parent, oop, results)
if isSameSource(src, start) then
return
end
+ if used[key] then
+ return
+ end
+ used[key] = true
local name = key:sub(3)
if not matchKey(word, name) then
return
@@ -259,6 +263,7 @@ local function checkFieldThen(src, results, word, start, parent, oop, results)
}
end),
})
+ return
end
if oop then
return
@@ -266,12 +271,8 @@ local function checkFieldThen(src, results, word, start, parent, oop, results)
local literal = guide.getLiteral(value)
if literal ~= nil then
kind = ckind.Enum
- else
- if results[name] then
- return
- end
end
- results[name] = {
+ results[#results+1] = {
label = name,
kind = kind,
id = stack(function ()
@@ -284,13 +285,10 @@ local function checkFieldThen(src, results, word, start, parent, oop, results)
end
local function checkField(word, start, parent, oop, results)
- local fields = {}
+ local used = {}
vm.eachField(parent, function (src)
- checkFieldThen(src, fields, word, start, parent, oop, fields)
+ checkFieldThen(src, word, start, parent, oop, results, used)
end)
- for _, result in pairs(fields) do
- results[#results+1] = result
- end
end
local function checkTableField(ast, word, start, results)