summaryrefslogtreecommitdiff
path: root/script-beta/core/completion.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-10 10:52:33 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-10 10:52:33 +0800
commitcc5e87de72ce1ab76c60149da7aa5d65dc807342 (patch)
tree4a4c4cb85c6d57dca5dde95e872f843478b89f20 /script-beta/core/completion.lua
parent329fffd8d658d2fdbf8484824cdd32fd4b3e186c (diff)
downloadlua-language-server-cc5e87de72ce1ab76c60149da7aa5d65dc807342.zip
修正一些bug
Diffstat (limited to 'script-beta/core/completion.lua')
-rw-r--r--script-beta/core/completion.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 35e4e21f..1f78b4d4 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -67,18 +67,24 @@ local function findParent(ast, text, offset)
end
local function checkLocal(ast, word, offset, results)
- guide.getVisibleLocalNames(ast.ast, offset, function (name)
+ local locals = guide.getVisibleLocals(ast.ast, offset)
+ for name in pairs(locals) do
if matchKey(word, name) then
results[#results+1] = {
label = name,
kind = ckind.Variable,
}
end
- end)
+ end
+end
+
+local function isSameSource(source, pos)
+ return source.start <= pos and source.finish >= pos
end
local function checkField(ast, text, word, offset, results)
- local parent, oop = findParent(ast, text, offset - #word)
+ local myStart = offset - #word + 1
+ local parent, oop = findParent(ast, text, myStart - 1)
if not parent then
parent = guide.getLocal(ast.ast, '_ENV', offset)
if not parent then
@@ -90,7 +96,7 @@ local function checkField(ast, text, word, offset, results)
local key = info.key
if key
and key:sub(1, 1) == 's'
- and info.source.finish ~= offset then
+ and not isSameSource(info.source, myStart) then
local name = key:sub(3)
if not used[name] and matchKey(word, name) then
results[#results+1] = {