diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-15 18:03:34 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-15 18:03:34 +0800 |
commit | 2426bbe0758801ecfe4369d72f6755e9ef193cc5 (patch) | |
tree | 28fd3385b767b6eea451b1cbc95bce624ce9a879 /script/core/diagnostics | |
parent | 4e68872ea96a53f9c7ad5e11c83794b92f477fb4 (diff) | |
download | lua-language-server-2426bbe0758801ecfe4369d72f6755e9ef193cc5.zip |
diagnostic: improve `newline-call`
Diffstat (limited to 'script/core/diagnostics')
-rw-r--r-- | script/core/diagnostics/newline-call.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/script/core/diagnostics/newline-call.lua b/script/core/diagnostics/newline-call.lua index c2c8bd66..807f76a2 100644 --- a/script/core/diagnostics/newline-call.lua +++ b/script/core/diagnostics/newline-call.lua @@ -3,8 +3,9 @@ local guide = require 'core.guide' local lang = require 'language' return function (uri, callback) - local ast = files.getAst(uri) + local ast = files.getAst(uri) local lines = files.getLines(uri) + local text = files.getText(uri) if not ast or not lines then return end @@ -20,6 +21,10 @@ return function (uri, callback) if not source.next then return end + if text:sub(args.start, args.start) ~= '(' + or text:sub(args.finish, args.finish) ~= ')' then + return + end local nodeRow = guide.positionOf(lines, node.finish) local argRow = guide.positionOf(lines, args.start) @@ -29,9 +34,9 @@ return function (uri, callback) if #args == 1 then callback { - start = args.start, + start = node.start, finish = args.finish, - message = lang.script.DIAG_PREVIOUS_CALL, + message = lang.script('DIAG_PREVIOUS_CALL', text:sub(node.start, node.finish), text:sub(args.start, args.finish)), } end end) |