summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-16 14:56:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-16 14:56:35 +0800
commit5737d55897545813e1f84de8adde2a046d3904f7 (patch)
tree5ebfaa0b9b21d8496add05eb37e5d4af66f01b0f /script-beta
parent605842f4792b4f7503c20bc1d111f7fecc6bde9f (diff)
downloadlua-language-server-5737d55897545813e1f84de8adde2a046d3904f7.zip
完善参数提示
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/signature.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/script-beta/core/signature.lua b/script-beta/core/signature.lua
index a833c3c7..fcf3fb63 100644
--- a/script-beta/core/signature.lua
+++ b/script-beta/core/signature.lua
@@ -4,11 +4,18 @@ local vm = require 'vm'
local hoverLabel = require 'core.hover.label'
local hoverDesc = require 'core.hover.description'
-local function findNearCall(ast, pos)
+local function findNearCall(uri, ast, pos)
+ local text = files.getText(uri)
+ -- 检查 `f()$` 的情况,注意要区别于 `f($`
+ if text:sub(pos, pos) == ')' then
+ return nil
+ end
+
local nearCall
guide.eachSourceContain(ast.ast, pos, function (src)
if src.type == 'call'
- or src.type == 'table' then
+ or src.type == 'table'
+ or src.type == 'function' then
if not nearCall or nearCall.start < src.start then
nearCall = src
end
@@ -85,7 +92,7 @@ return function (uri, pos)
if not ast then
return nil
end
- local call = findNearCall(ast, pos)
+ local call = findNearCall(uri, ast, pos)
if not call then
return nil
end