Skip to content

Commit

Permalink
fix #379 semantic-tokens supports plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Feb 4, 2021
1 parent cf2c5fe commit 09377c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* `FIX` [#375](https://github.com/sumneko/lua-language-server/issues/375)
* `FIX` [#376](https://github.com/sumneko/lua-language-server/issues/376)
* `FIX` [#378](https://github.com/sumneko/lua-language-server/issues/378)
* `FIX` [#379](https://github.com/sumneko/lua-language-server/issues/379)

## 1.14.1
`2021-2-2`
Expand Down
15 changes: 7 additions & 8 deletions script/core/semantic-tokens.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ Care['nonstandardSymbol.continue'] = function (source, results)
}
end

local function buildTokens(results, text, lines)
local function buildTokens(uri, results)
local tokens = {}
local lastLine = 0
local lastStartChar = 0
for i, source in ipairs(results) do
local row, col = guide.positionOf(lines, source.start)
local start = guide.lineRange(lines, row)
local ucol = util.utf8Len(text, start, start + col - 1)
local line = row - 1
local startChar = ucol - 1
local startPos = files.position(uri, source.start)
local finishPos = files.position(uri, source.finish)
local line = startPos.line
local startChar = startPos.character - 1
local deltaLine = line - lastLine
local deltaStartChar
if deltaLine == 0 then
Expand All @@ -158,7 +157,7 @@ local function buildTokens(results, text, lines)
local len = i * 5 - 5
tokens[len + 1] = deltaLine
tokens[len + 2] = deltaStartChar
tokens[len + 3] = source.finish - source.start + 1 -- length
tokens[len + 3] = finishPos.character - startPos.character + 1 -- length
tokens[len + 4] = source.type
tokens[len + 5] = source.modifieres or 0
end
Expand Down Expand Up @@ -201,7 +200,7 @@ return function (uri, start, finish)
return a.start < b.start
end)

local tokens = buildTokens(results, text, lines)
local tokens = buildTokens(uri, results)

return tokens
end

0 comments on commit 09377c7

Please sign in to comment.