summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/completion/completion.lua10
-rw-r--r--test/completion/common.lua45
2 files changed, 47 insertions, 8 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index cff9c385..3a76472a 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1588,18 +1588,12 @@ end
local function findCall(state, position)
local call
guide.eachSourceContain(state.ast, position, function (src)
- if src.type == 'call' then
- if not call or call.start < src.start then
+ if src.type == 'call' and src.node.finish <= position then
+ if not call or call.start < src.start then
call = src
end
end
end)
- if not call then
- return nil
- end
- if call.node.finish > position then
- return nil
- end
return call
end
diff --git a/test/completion/common.lua b/test/completion/common.lua
index fc2183d7..ec2372a0 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -4489,3 +4489,48 @@ local m
m:self(<??>):optional()
]]
(nil)
+
+TEST [[
+---@enum(key) enum
+local t = {
+ a = 1,
+ b = 2,
+ c = 3,
+}
+
+---@class A
+local M
+
+---@return A
+function M.create()
+ return M
+end
+
+---@param optional enum
+---@return self
+function M:optional(optional)
+ return self
+end
+
+---@return A
+function M:self()
+ return self
+end
+
+
+M.create():optional(<??>):self()
+]]
+{
+ {
+ label = '"a"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+ {
+ label = '"b"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+ {
+ label = '"c"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+}