diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-02-04 15:59:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-02-04 15:59:46 +0800 |
commit | 09377c7ce742bdc29e9c5532d122ae39019345f3 (patch) | |
tree | e2ea2c3532c48dfb791c9072e0ec4a07d00b2315 | |
parent | cf2c5fee7f6f9b3e49930f34390671b9b267f9d7 (diff) | |
download | lua-language-server-09377c7ce742bdc29e9c5532d122ae39019345f3.zip |
fix #379 semantic-tokens supports plugin
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/semantic-tokens.lua | 15 |
2 files changed, 8 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md index 2a2f8bdf..cca22554 100644 --- a/changelog.md +++ b/changelog.md @@ -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` diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index 73e0337b..56bfb5ef 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -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 @@ -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 @@ -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 |