summaryrefslogtreecommitdiff
path: root/server/test/completion/init.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-06 17:51:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-06 17:51:35 +0800
commitf9b3e7070d4239687e8db16393b81213c4a701cd (patch)
treec0498f6834e55b2d477eff086b43d4824fd89956 /server/test/completion/init.lua
parentca0341d0760a067b6554d5b7aeb8357ec84e564f (diff)
downloadlua-language-server-f9b3e7070d4239687e8db16393b81213c4a701cd.zip
向前找符号
Diffstat (limited to 'server/test/completion/init.lua')
-rw-r--r--server/test/completion/init.lua32
1 files changed, 31 insertions, 1 deletions
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 874b0948..cc2c36be 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -68,6 +68,20 @@ local function findStartPos(pos, buf)
break
end
end
+ if not res then
+ for i = pos-1, 1, -1 do
+ local c = buf:sub(i, i)
+ if c:find '[%.%:]' then
+ res = i
+ elseif c:find '[%s%c]' then
+ else
+ break
+ end
+ end
+ end
+ if not res then
+ return pos
+ end
return res
end
@@ -93,7 +107,7 @@ function TEST(script)
local vm = buildVM(ast)
assert(vm)
local word = findWord(pos, new_script)
- local startPos = findStartPos(pos, new_script) or pos
+ local startPos = findStartPos(pos, new_script)
local result = core.completion(vm, startPos, word)
if expect then
assert(result)
@@ -262,6 +276,22 @@ t.@
TEST [[
t.a = {}
+t.b = {}
+t. @
+]]
+{
+ {
+ label = 'a',
+ kind = CompletionItemKind.Field,
+ },
+ {
+ label = 'b',
+ kind = CompletionItemKind.Field,
+ },
+}
+
+TEST [[
+t.a = {}
function t:b()
end
t:@