Skip to content

Commit d512a42

Browse files
committed
fix wrong semantic-tokens when skipping empty char
see neovim/neovim#22607
1 parent dadeadf commit d512a42

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

script/core/semantic-tokens.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ local function buildTokens(state, results)
710710
local tokens = {}
711711
local lastLine = 0
712712
local lastStartChar = 0
713-
for i, source in ipairs(results) do
713+
local index = 0
714+
for _, source in ipairs(results) do
714715
local startPos = source.start
715716
local finishPos = source.finish
716717
local line = startPos.line
@@ -728,7 +729,8 @@ local function buildTokens(state, results)
728729
lastLine = line
729730
lastStartChar = startChar
730731
-- see https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#textDocument_semanticTokens
731-
local len = i * 5 - 5
732+
index = index + 1
733+
local len = index * 5 - 5
732734
tokens[len + 1] = deltaLine
733735
tokens[len + 2] = deltaStartChar
734736
tokens[len + 3] = finishPos.character - startPos.character -- length

0 commit comments

Comments
 (0)