diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/signature.lua | 21 | ||||
-rw-r--r-- | server/test/signature/init.lua | 11 |
2 files changed, 32 insertions, 0 deletions
diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua index 1e629308..ca20f054 100644 --- a/server/src/core/signature.lua +++ b/server/src/core/signature.lua @@ -67,6 +67,22 @@ local function getHover(call, pos) end end +local function isInFunctionOrTable(call, pos) + local func, args = call:bindCall() + if not func then + return false + end + local select = getSelect(args, pos) + local arg = args[select] + if not arg then + return false + end + if arg.type == 'function' or arg.type == 'table' then + return true + end + return false +end + return function (vm, pos) local source = findSource(vm, pos) or findSource(vm, pos-1) if not source or source.type == 'string' then @@ -77,6 +93,11 @@ return function (vm, pos) return nil end + local nearCall = calls[1] + if isInFunctionOrTable(nearCall, pos) then + return nil + end + local hovers = {} for _, call in ipairs(calls) do hovers[#hovers+1] = getHover(call, pos) diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua index cf335f05..3e83b5ba 100644 --- a/server/test/signature/init.lua +++ b/server/test/signature/init.lua @@ -13,6 +13,7 @@ function TEST(script) assert(vm) local hovers = core.signature(vm, pos) if hovers then + assert(expect) local hover = hovers[#hovers] local label = hover.label:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') @@ -106,3 +107,13 @@ end f(1, 'string@') ]] (nil) + +TEST [[ +pcall(function () @ end) +]] +(nil) + +TEST [[ +table.unpack {@} +]] +(nil) |