summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/completion/completion.lua2
-rw-r--r--test/completion/common.lua22
2 files changed, 20 insertions, 4 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 969de95a..eadf2739 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1401,7 +1401,7 @@ local function getCallEnumsAndFuncs(source, index, oop, call)
and doc.field[1] == source[1] then
local eventName = noder.getFieldEventName(doc)
if eventName and eventName == myEventName then
- local docFunc = doc.extends.types[1].args[2].extends.types[1]
+ local docFunc = doc.extends.types[1].args[index].extends.types[1]
results[#results+1] = {
label = infer.viewDocFunction(docFunc),
description = doc.comment,
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 787549f7..22d9f554 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -2640,9 +2640,9 @@ class2:<??>
TEST [[
--- @class Emit
---- @field on fun(eventName: string, cb: function)
---- @field on fun(eventName: '"died"', cb: fun(i: integer))
---- @field on fun(eventName: '"won"', cb: fun(s: string))
+--- @field on fun(self: Emit, eventName: string, cb: function)
+--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer))
+--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string))
local emit = {}
emit:on('<??>')
@@ -2656,6 +2656,22 @@ TEST [[
--- @field on fun(eventName: '"won"', cb: fun(s: string))
local emit = {}
+emit.on('died', <??>)
+]]
+{
+ [1] = {
+ label = 'fun(i: integer)',
+ kind = define.CompletionItemKind.Function,
+ }
+}
+
+TEST [[
+--- @class Emit
+--- @field on fun(self: Emit, eventName: string, cb: function)
+--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer))
+--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string))
+local emit = {}
+
emit:on('won', <??>)
]]
{