summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-03-11 17:59:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-03-11 17:59:22 +0800
commitd512a42ba2abb0959b74ef3f9bfe05d042e47738 (patch)
tree687b93c7c794cdfc502a5da7c073d9a301bce2a9 /script/core
parentdadeadf34dd92c52635d120c7fb2cfa30701cd22 (diff)
downloadlua-language-server-d512a42ba2abb0959b74ef3f9bfe05d042e47738.zip
fix wrong semantic-tokens when skipping empty char
see https://github.com/neovim/neovim/pull/22607
Diffstat (limited to 'script/core')
-rw-r--r--script/core/semantic-tokens.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index 116f7e53..0e27e8b8 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -710,7 +710,8 @@ local function buildTokens(state, results)
local tokens = {}
local lastLine = 0
local lastStartChar = 0
- for i, source in ipairs(results) do
+ local index = 0
+ for _, source in ipairs(results) do
local startPos = source.start
local finishPos = source.finish
local line = startPos.line
@@ -728,7 +729,8 @@ local function buildTokens(state, results)
lastLine = line
lastStartChar = startChar
-- see https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#textDocument_semanticTokens
- local len = i * 5 - 5
+ index = index + 1
+ local len = index * 5 - 5
tokens[len + 1] = deltaLine
tokens[len + 2] = deltaStartChar
tokens[len + 3] = finishPos.character - startPos.character -- length