diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-22 15:22:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-22 15:22:44 +0800 |
commit | 375fde95ee4ac26d23f9a664ee2d794c8aceb6fc (patch) | |
tree | db1c76002a7f4595f85a53ed0521327e3b0996fa /script/library.lua | |
parent | df5bd5457ad450a0f57553ee587280bd79b43072 (diff) | |
download | lua-language-server-375fde95ee4ac26d23f9a664ee2d794c8aceb6fc.zip |
fix #402 should not match `.` as last character
Diffstat (limited to 'script/library.lua')
-rw-r--r-- | script/library.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/script/library.lua b/script/library.lua index 723e871a..c7cecef6 100644 --- a/script/library.lua +++ b/script/library.lua @@ -39,16 +39,26 @@ end local function convertLink(text) local fmt = getDocFormater() return text:gsub('%$([%.%w]+)', function (name) + local lastDot = '' + if name:sub(-1) == '.' then + name = name:sub(1, -2) + lastDot = '.' + end if fmt then - return ('[%s](%s)'):format(name, lang.script(fmt, 'pdf-' .. name)) + return ('[%s](%s)'):format(name, lang.script(fmt, 'pdf-' .. name)) .. lastDot else - return ('`%s`'):format(name) + return ('`%s`'):format(name) .. lastDot end end):gsub('§([%.%w]+)', function (name) + local lastDot = '' + if name:sub(-1) == '.' then + name = name:sub(1, -2) + lastDot = '.' + end if fmt then - return ('[§%s](%s)'):format(name, lang.script(fmt, name)) + return ('[§%s](%s)'):format(name, lang.script(fmt, name)) .. lastDot else - return ('`%s`'):format(name) + return ('`%s`'):format(name) .. lastDot end end) end @@ -59,6 +69,9 @@ local function createViewDocument(name) return nil end name = name:match '[%w_%.]+' + if name:sub(-1) == '.' then + name = name:sub(1, -2) + end return ('[%s](%s)'):format(lang.script.HOVER_VIEW_DOCUMENTS, lang.script(fmt, 'pdf-' .. name)) end |