diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-01 19:17:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-01 19:17:22 +0800 |
commit | 1608befdb482355744cda0b6891aaf68a9d662c3 (patch) | |
tree | 6cc542934d283067793eb5650f0466c7dc378075 /script | |
parent | e9c319ac7c512b3563101c87d73d959931e1554a (diff) | |
parent | 5e63a4d05d18e7529abcbd6f52ae71078e81f9ef (diff) | |
download | lua-language-server-1608befdb482355744cda0b6891aaf68a9d662c3.zip |
Merge pull request #936 from kevinhwang91/limit-semantictoken-range
fix(semantic-tokens): limit comments range
Diffstat (limited to 'script')
-rw-r--r-- | script/core/semantic-tokens.lua | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index afa1424b..6163cbbe 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -815,21 +815,29 @@ 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, @@ -837,12 +845,6 @@ return function (uri, start, finish) type = define.TokenTypes.comment, } end - else - results[#results+1] = { - start = comm.start, - finish = comm.finish, - type = define.TokenTypes.comment, - } end end |