diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-07 16:47:10 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-07 16:47:10 +0800 |
commit | 1face5ab84618c03ad3077252ae289774ce7a816 (patch) | |
tree | e01a038c43f5f473a4bf657b538efedaaa980a01 | |
parent | 2107c1c82bccaaf2e2cce937412ef8d5e8741b45 (diff) | |
download | lua-language-server-1face5ab84618c03ad3077252ae289774ce7a816.zip |
fix #975
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/semantic-tokens.lua | 11 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 11 |
3 files changed, 12 insertions, 11 deletions
diff --git a/changelog.md b/changelog.md index 47411faa..4f885750 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ * `NEW` offline diagnostic, [read more](https://github.com/sumneko/lua-language-server/wiki/Offline-Diagnostic) * `CHG` `VSCode`: 1.65 has built in new `Lua` syntax files, so this extension no longer provides syntax files, which means you can install other syntax extensions in the marketplace. If you have any suggestions or issues, please [open issues here](https://github.com/sumneko/lua.tmbundle). * `FIX` [#965](https://github.com/sumneko/lua-language-server/issues/965) +* `FIX` [#975](https://github.com/sumneko/lua-language-server/issues/975) ## 2.6.6 `2022-2-21` diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index a4429e03..c5a77563 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -817,17 +817,16 @@ return function (uri, start, finish) for _, comm in ipairs(state.comms) do if start <= comm.start and comm.finish <= finish then if comm.type == 'comment.short' then - local head = comm.text:sub(1, 2) - if head == '-@' - or head == '-|' then + local head = comm.text:match '^%-%s*[@|]' + if head then results[#results+1] = { start = comm.start, - finish = comm.start + 3, + finish = comm.start + #head + 1, type = define.TokenTypes.comment, } results[#results+1] = { - start = comm.start + 3, - finish = comm.start + 2 + #comm.text:match '%S+', + start = comm.start + #head + 1, + finish = comm.start + #head + 2 + #comm.text:match('%S+', #head + 1), type = define.TokenTypes.keyword, modifieres = define.TokenModifiers.documentation, } diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index a47ebe34..d15fd95a 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -668,20 +668,21 @@ function parseType(parent) if currentRow < nextCommRow then return false end - if nextComm.text:sub(1, 2) == '-@' then + if nextComm.text:match '^%-%s*%@' then return false else - if nextComm.text:sub(1, 2) == '-|' then + local resumeHead = nextComm.text:match '^%-%s*%|' + if resumeHead then NextComment(i) row = row + i + 1 - local finishPos = nextComm.text:find('#', 3) or #nextComm.text - parseTokens(nextComm.text:sub(3, finishPos), nextComm.start + 3) + local finishPos = nextComm.text:find('#', #resumeHead + 1) or #nextComm.text + parseTokens(nextComm.text:sub(#resumeHead + 1, finishPos), nextComm.start + #resumeHead + 1) local resume = parseResume(result) if resume then if comments then resume.comment = table.concat(comments, '\n') else - resume.comment = nextComm.text:match('#%s*(.+)', 3) + resume.comment = nextComm.text:match('#%s*(.+)', #resumeHead + 1) end result.types[#result.types+1] = resume result.finish = resume.finish |