summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-06 20:37:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-06 20:37:24 +0800
commit29b0c7064b1a0d623867c1136b84e5f1b5038f9a (patch)
tree6d914d02c11d22d777d82fdd803e529ebce27507
parent9471213c956223fc9746d77b2082cd970c6617f8 (diff)
downloadlua-language-server-29b0c7064b1a0d623867c1136b84e5f1b5038f9a.zip
fix #842
-rw-r--r--changelog.md1
-rw-r--r--script/core/completion/completion.lua14
-rw-r--r--test/completion/common.lua27
3 files changed, 26 insertions, 16 deletions
diff --git a/changelog.md b/changelog.md
index 05969225..c805e92d 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,7 @@
# changelog
## 2.5.3
+* `FIX` [#842](https://github.com/sumneko/lua-language-server/issues/844)
* `FIX` [#844](https://github.com/sumneko/lua-language-server/issues/844)
## 2.5.2
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index ba2b0efc..cb2ce8dd 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1354,20 +1354,6 @@ local function getCallEnumsAndFuncs(source, index, oop, call)
end
end
if source.type == 'doc.type.function' then
- --[[
- always use literal index, that is:
- ```
- ---@class Class
- ---@field f(x: number, y: boolean)
- local c
-
- c.f(1, true) -- correct
- c:f(1, true) -- also correct
- ```
- --]]
- if oop then
- index = index - 1
- end
local arg = source.args[index]
if arg and arg.extends then
return pushCallEnumsAndFuncs(vm.getDefs(arg.extends))
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 3a3d1d46..73337e58 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -2593,7 +2593,7 @@ c:<??>
TEST [[
---@class Class
----@field on fun(x: "'aaa'"|"'bbb'")
+---@field on fun(self, x: "'aaa'"|"'bbb'")
local c
c:on(<??>)
@@ -2605,7 +2605,7 @@ TEST [[
---@field on fun(x: "'aaa'"|"'bbb'")
local c
-c:on('<??>')
+c.on('<??>')
]]
(EXISTS)
@@ -3037,3 +3037,26 @@ end)
}
},
}
+
+TEST [[
+---@meta
+
+---@alias testAlias
+---| "'test1'"
+---| "'test2'"
+---| "'test3'"
+
+---@class TestClass
+local TestClass = {}
+
+---@overload fun(self: TestClass, arg2: testAlias)
+---@param arg1 integer
+---@param arg2 testAlias
+function TestClass:testFunc2(arg1, arg2) end
+
+---@type TestClass
+local t
+
+t:testFunc2(<??>)
+]]
+(EXISTS)