summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-28 21:39:29 +0800
committersumneko <sumneko@hotmail.com>2019-04-28 21:39:29 +0800
commitc33348a12256d6f8cff17960f037d9615c002276 (patch)
treed7447d4ab8f45ac5ae4edf6b47bd4a436c00605d /server
parent2793fe8003d10c5d7db54a63f3e6140ce305fb92 (diff)
downloadlua-language-server-c33348a12256d6f8cff17960f037d9615c002276.zip
修正关键字有时捕获不到的bug
Diffstat (limited to 'server')
-rw-r--r--server/src/core/completion.lua9
-rw-r--r--server/src/utility.lua2
-rw-r--r--server/test/completion/init.lua27
3 files changed, 34 insertions, 4 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 8659901f..c8147f9e 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -761,13 +761,16 @@ end
local function getSource(vm, pos, text, filter)
local word = findWord(pos, text)
- local source = findSource(vm, pos, filter)
+ local source = keywordSource(vm, word, pos)
+ if source then
+ return source, pos, word
+ end
+ source = findSource(vm, pos, filter)
if source then
return source, pos, word
end
pos = findStartPos(pos, text)
- source = findSource(vm, pos, filter)
- or keywordSource(vm, word, pos)
+ source = findSource(vm, pos, filter)
return source, pos, word
end
diff --git a/server/src/utility.lua b/server/src/utility.lua
index 9bca93a5..4e390597 100644
--- a/server/src/utility.lua
+++ b/server/src/utility.lua
@@ -27,7 +27,7 @@ function table.dump(tbl)
local lines = {}
lines[#lines+1] = '{'
local function unpack(tbl, tab)
- if tab > 100 then
+ if tab > 10 then
return '<Deep Table>'
end
local keys = {}
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 7d0d1d04..17ab0369 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -1028,3 +1028,30 @@ mt.$
kind = CompletionItemKind.Field,
},
}
+
+TEST [[
+local function f()
+ if a then
+ else$
+end
+]]
+{
+ {
+ label = 'select',
+ kind = CompletionItemKind.Function,
+ documentation = EXISTS,
+ },
+ {
+ label = 'setmetatable',
+ kind = CompletionItemKind.Function,
+ documentation = EXISTS,
+ },
+ {
+ label = 'else',
+ kind = CompletionItemKind.Keyword,
+ },
+ {
+ label = 'elseif',
+ kind = CompletionItemKind.Keyword,
+ },
+}