Skip to content

Commit 1face5a

Browse files
committed
fix #975
1 parent 2107c1c commit 1face5a

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* `NEW` offline diagnostic, [read more](https://github.com/sumneko/lua-language-server/wiki/Offline-Diagnostic)
55
* `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).
66
* `FIX` [#965](https://github.com/sumneko/lua-language-server/issues/965)
7+
* `FIX` [#975](https://github.com/sumneko/lua-language-server/issues/975)
78

89
## 2.6.6
910
`2022-2-21`

script/core/semantic-tokens.lua

+5-6
Original file line numberDiff line numberDiff line change
@@ -817,17 +817,16 @@ return function (uri, start, finish)
817817
for _, comm in ipairs(state.comms) do
818818
if start <= comm.start and comm.finish <= finish then
819819
if comm.type == 'comment.short' then
820-
local head = comm.text:sub(1, 2)
821-
if head == '-@'
822-
or head == '-|' then
820+
local head = comm.text:match '^%-%s*[@|]'
821+
if head then
823822
results[#results+1] = {
824823
start = comm.start,
825-
finish = comm.start + 3,
824+
finish = comm.start + #head + 1,
826825
type = define.TokenTypes.comment,
827826
}
828827
results[#results+1] = {
829-
start = comm.start + 3,
830-
finish = comm.start + 2 + #comm.text:match '%S+',
828+
start = comm.start + #head + 1,
829+
finish = comm.start + #head + 2 + #comm.text:match('%S+', #head + 1),
831830
type = define.TokenTypes.keyword,
832831
modifieres = define.TokenModifiers.documentation,
833832
}

script/parser/luadoc.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -668,20 +668,21 @@ function parseType(parent)
668668
if currentRow < nextCommRow then
669669
return false
670670
end
671-
if nextComm.text:sub(1, 2) == '-@' then
671+
if nextComm.text:match '^%-%s*%@' then
672672
return false
673673
else
674-
if nextComm.text:sub(1, 2) == '-|' then
674+
local resumeHead = nextComm.text:match '^%-%s*%|'
675+
if resumeHead then
675676
NextComment(i)
676677
row = row + i + 1
677-
local finishPos = nextComm.text:find('#', 3) or #nextComm.text
678-
parseTokens(nextComm.text:sub(3, finishPos), nextComm.start + 3)
678+
local finishPos = nextComm.text:find('#', #resumeHead + 1) or #nextComm.text
679+
parseTokens(nextComm.text:sub(#resumeHead + 1, finishPos), nextComm.start + #resumeHead + 1)
679680
local resume = parseResume(result)
680681
if resume then
681682
if comments then
682683
resume.comment = table.concat(comments, '\n')
683684
else
684-
resume.comment = nextComm.text:match('#%s*(.+)', 3)
685+
resume.comment = nextComm.text:match('#%s*(.+)', #resumeHead + 1)
685686
end
686687
result.types[#result.types+1] = resume
687688
result.finish = resume.finish

0 commit comments

Comments
 (0)