summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-22 14:40:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-22 14:40:22 +0800
commit2e57e65b6fa218d9de47473628940f8d2db43f79 (patch)
tree9629a1cec1de6c025c2bf5eb9b1b086dd72d5e6f
parent892f85f606d166960b66a8aba2e36215d648b311 (diff)
downloadlua-language-server-2e57e65b6fa218d9de47473628940f8d2db43f79.zip
#400 fix signature behind `}`
-rw-r--r--changelog.md1
-rw-r--r--script/core/signature.lua7
-rw-r--r--test/signature/init.lua13
3 files changed, 20 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md
index 9d2ee696..c455c90a 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
## 1.16.1
* `FIX` signature: parameters may be misplaced
+* `FIX` [#400](https://github.com/sumneko/lua-language-server/issues/400)
* `FIX` runtime errors
## 1.16.0
diff --git a/script/core/signature.lua b/script/core/signature.lua
index 6e3d7e11..ab6d133a 100644
--- a/script/core/signature.lua
+++ b/script/core/signature.lua
@@ -11,11 +11,16 @@ local function findNearCall(uri, ast, pos)
if src.type == 'call'
or src.type == 'table'
or src.type == 'function' then
- -- call()$
+ -- call(),$
if src.finish <= pos
and text:sub(src.finish, src.finish) == ')' then
return
end
+ -- {},$
+ if src.finish <= pos
+ and text:sub(src.finish, src.finish) == '}' then
+ return
+ end
if not nearCall or nearCall.start < src.start then
nearCall = src
end
diff --git a/test/signature/init.lua b/test/signature/init.lua
index fca995bd..c7b9a137 100644
--- a/test/signature/init.lua
+++ b/test/signature/init.lua
@@ -190,3 +190,16 @@ function f2(c: any, d: any)
]],
arg = {21, 26},
}
+
+TEST [[
+local function f(a, b, c)
+end
+
+f({},$)
+]]
+{
+ label = [[
+function f(a: any, b: any, c: any)
+]],
+ arg = {20, 25},
+}