Skip to content

Commit

Permalink
Merge pull request #936 from kevinhwang91/limit-semantictoken-range
Browse files Browse the repository at this point in the history
fix(semantic-tokens): limit comments range
  • Loading branch information
sumneko authored Feb 1, 2022
2 parents e9c319a + 5e63a4d commit 1608bef
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions script/core/semantic-tokens.lua
Original file line number Diff line number Diff line change
Expand Up @@ -815,34 +815,36 @@ return function (uri, start, finish)
end)

for _, comm in ipairs(state.comms) do
if comm.type == 'comment.short' then
local head = comm.text:sub(1, 2)
if head == '-@'
or head == '-|' then
results[#results+1] = {
start = comm.start,
finish = comm.start + 3,
type = define.TokenTypes.comment,
}
results[#results+1] = {
start = comm.start + 3,
finish = comm.start + 2 + #comm.text:match '%S+',
type = define.TokenTypes.comment,
modifieres = define.TokenModifiers.documentation,
}
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
results[#results+1] = {
start = comm.start,
finish = comm.start + 3,
type = define.TokenTypes.comment,
}
results[#results+1] = {
start = comm.start + 3,
finish = comm.start + 2 + #comm.text:match '%S+',
type = define.TokenTypes.comment,
modifieres = define.TokenModifiers.documentation,
}
else
results[#results+1] = {
start = comm.start,
finish = comm.finish,
type = define.TokenTypes.comment,
}
end
else
results[#results+1] = {
start = comm.start,
finish = comm.finish,
type = define.TokenTypes.comment,
}
end
else
results[#results+1] = {
start = comm.start,
finish = comm.finish,
type = define.TokenTypes.comment,
}
end
end

Expand Down

0 comments on commit 1608bef

Please sign in to comment.