summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-25 12:42:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-25 12:42:53 +0800
commite76dd6108712200905e05edef73f6e71bcab40ff (patch)
treebcf06ee48f9618d4719f6167bb6c39b95cb3227c /server
parentac80195615204ef256736e3ef487ea5143fe86d1 (diff)
downloadlua-language-server-e76dd6108712200905e05edef73f6e71bcab40ff.zip
参数的自动完成添加可见局部变量
Diffstat (limited to 'server')
-rw-r--r--server/src/core/completion.lua3
-rw-r--r--server/test/completion/init.lua14
2 files changed, 16 insertions, 1 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 67b03213..54f96295 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -250,8 +250,9 @@ local function searchCloseGlobal(vm, source, word, callback)
end
local close = loc:close()
-- 因为闭包的关系落在局部变量finish到close范围内的全局变量一定能访问到该局部变量
+
for _, src in ipairs(vm.sources) do
- if src:get 'global'
+ if (src:get 'global' or src:bindLocal())
and src.start >= source.finish
and src.finish <= close
then
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index fec6f105..14c14476 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -684,3 +684,17 @@ local t = 'as@'
local ask = 1
]]
(nil)
+
+TEST [[
+local add
+
+function f(a@)
+ local _ = add
+end
+]]
+{
+ {
+ label = 'add',
+ kind = CompletionItemKind.Variable,
+ },
+}