diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/signature.lua | 7 | ||||
-rw-r--r-- | test/signature/init.lua | 13 |
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}, +} |