From 2e57e65b6fa218d9de47473628940f8d2db43f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 22 Feb 2021 14:40:22 +0800 Subject: #400 fix signature behind `}` --- changelog.md | 1 + script/core/signature.lua | 7 ++++++- test/signature/init.lua | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) 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}, +} -- cgit v1.2.3