summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-06 15:00:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-06 15:00:23 +0800
commitbd1196c1b2f6c0722deb765359e5a0702c31644c (patch)
tree09785ad6500fd969c49a418ac9d9c2cf12ebf6b3
parent73b5e9eb4d6eb08792b36c9a6b89e9fc69497d7c (diff)
downloadlua-language-server-bd1196c1b2f6c0722deb765359e5a0702c31644c.zip
fix #488
-rw-r--r--changelog.md1
-rw-r--r--script/core/completion.lua5
-rw-r--r--test/completion/init.lua11
3 files changed, 15 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md
index 9d88fed2..4c5ef3eb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,7 @@
`FIX` [#483](https://github.com/sumneko/lua-language-server/issues/483)
`FIX` [#485](https://github.com/sumneko/lua-language-server/issues/485)
`FIX` [#487](https://github.com/sumneko/lua-language-server/issues/487)
+`FIX` [#488](https://github.com/sumneko/lua-language-server/issues/488)
## 1.20.2
`2021-4-2`
diff --git a/script/core/completion.lua b/script/core/completion.lua
index b01699a6..a8a881a7 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1333,7 +1333,7 @@ local function checkTableLiteralField(ast, text, offset, tbl, fields, results)
end
end
-local function checkTableLiteralFieldByCall(ast, text, offset, call, funcs, index, results)
+local function checkTableLiteralFieldByCall(ast, text, offset, call, defs, index, results)
local source = findNearestSource(ast, offset)
if not source then
return
@@ -1354,7 +1354,8 @@ local function checkTableLiteralFieldByCall(ast, text, offset, call, funcs, inde
if tbl.parent ~= call.args then
return
end
- for _, func in ipairs(funcs) do
+ for _, def in ipairs(defs) do
+ local func = guide.getObjectValue(def) or def
local param = getFuncParamByCallIndex(func, index)
if not param then
goto CONTINUE
diff --git a/test/completion/init.lua b/test/completion/init.lua
index c648d379..b07fda90 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -2513,3 +2513,14 @@ local t = {
$
]]
(EXISTS)
+
+TEST [[
+---@class A
+---@field a '"hello"'|'"world"'
+
+---@param t A
+function api(t) end
+
+api({$})
+]]
+(EXISTS)