From 6c750bc0fcd0c76282ab61367d661c5e49844253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 14 Jul 2022 18:00:40 +0800 Subject: support char --- script/core/jump-source.lua | 8 ++++---- script/parser/luadoc.lua | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'script') diff --git a/script/core/jump-source.lua b/script/core/jump-source.lua index 76d7324b..15afae39 100644 --- a/script/core/jump-source.lua +++ b/script/core/jump-source.lua @@ -8,8 +8,8 @@ return function (results) if doc then result.uri = doc.source result.target.uri = doc.source - result.target.start = guide.positionOf(doc.line - 1, 0) - result.target.finish = guide.positionOf(doc.line - 1, 0) + result.target.start = guide.positionOf(doc.line - 1, doc.char) + result.target.finish = guide.positionOf(doc.line - 1, doc.char) end else local target = result.target @@ -23,8 +23,8 @@ return function (results) and doc.bindSource == target then result.uri = doc.source result.target.uri = doc.source - result.target.start = guide.positionOf(doc.line - 1, 0) - result.target.finish = guide.positionOf(doc.line - 1, 0) + result.target.start = guide.positionOf(doc.line - 1, doc.char) + result.target.finish = guide.positionOf(doc.line - 1, doc.char) end end end diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 91ed44c0..9ea99f39 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -1415,9 +1415,10 @@ local docSwitch = util.switch() if fullSource == '' then return end - local source, line = fullSource:match('^(.-):(%d+)$') + local source, line, char = fullSource:match('^(.-):?(%d*):?(%d*)$') source = source or fullSource line = tonumber(line) or 1 + char = tonumber(char) or 0 local uri if furi.split(source) then uri = source @@ -1430,6 +1431,7 @@ local docSwitch = util.switch() finish = getFinish(), source = uri, line = line, + char = char, } return result end) -- cgit v1.2.3