summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-18 22:59:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-18 22:59:29 +0800
commit583e9543f024e7f9b395599846194429bfc38a9c (patch)
tree2735eb8ed1e9cd486be27400f2cabedf77fa8e0d /script-beta/core
parent354989177fb38c9d550044ec7ef11a6f4a36f9c9 (diff)
downloadlua-language-server-583e9543f024e7f9b395599846194429bfc38a9c.zip
更新 completion
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/completion.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index f14ec495..b461094d 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -177,9 +177,16 @@ local function buildFunction(results, source, oop, data)
end
end
+local function isSameSource(source, pos)
+ return source.start <= pos and source.finish >= pos
+end
+
local function checkLocal(ast, word, offset, results)
local locals = guide.getVisibleLocals(ast.ast, offset)
for name, source in pairs(locals) do
+ if isSameSource(source, offset) then
+ goto CONTINUE
+ end
if not matchKey(word, name) then
goto CONTINUE
end
@@ -210,10 +217,6 @@ local function checkLocal(ast, word, offset, results)
end
end
-local function isSameSource(source, pos)
- return source.start <= pos and source.finish >= pos
-end
-
local function checkField(word, start, parent, oop, results)
local used = {}
vm.eachField(parent, function (info)
@@ -601,10 +604,12 @@ local function checkKeyWord(ast, text, start, word, hasSpace, afterLocal, result
end
if eq then
local replaced
+ local extra
if snipType == 'Both' or snipType == 'Replace' then
local func = data[2]
if func then
replaced = func(hasSpace, results)
+ extra = true
end
end
if snipType == 'Both' then
@@ -612,10 +617,15 @@ local function checkKeyWord(ast, text, start, word, hasSpace, afterLocal, result
end
if not replaced then
if not hasSpace then
- results[#results+1] = {
+ local item = {
label = key,
kind = ckind.Keyword,
}
+ if extra then
+ table.insert(results, #results, item)
+ else
+ results[#results+1] = item
+ end
end
end
local checkStop = data[3]