aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/semantic_tokens.lua
diff options
context:
space:
mode:
authorTristan Knight <admin@snappeh.com>2024-10-26 15:38:25 +0100
committerGitHub <noreply@github.com>2024-10-26 07:38:25 -0700
commit25b53b593ef6f229fbec5b3dc205a7539579d13a (patch)
tree8c13b6b78e22437b8fd22ac8b639ecc65417fff3 /runtime/lua/vim/lsp/semantic_tokens.lua
parentb922b7d6d7889cce863540df7b0da7d512f8a2a1 (diff)
downloadrneovim-25b53b593ef6f229fbec5b3dc205a7539579d13a.tar.gz
rneovim-25b53b593ef6f229fbec5b3dc205a7539579d13a.tar.bz2
rneovim-25b53b593ef6f229fbec5b3dc205a7539579d13a.zip
refactor(lsp): drop str_byteindex/str_utfindex wrappers #30915
* deprecate old signatures * move to new str_byteindex/str_utfindex signature * use single-underscore name (double-underscore is reserved for Lua itself)
Diffstat (limited to 'runtime/lua/vim/lsp/semantic_tokens.lua')
-rw-r--r--runtime/lua/vim/lsp/semantic_tokens.lua14
1 files changed, 4 insertions, 10 deletions
diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua
index 0f6e45c330..d680522592 100644
--- a/runtime/lua/vim/lsp/semantic_tokens.lua
+++ b/runtime/lua/vim/lsp/semantic_tokens.lua
@@ -137,16 +137,10 @@ local function tokens_to_ranges(data, bufnr, client, request)
local token_type = token_types[data[i + 3] + 1]
local modifiers = modifiers_from_number(data[i + 4], token_modifiers)
- local function _get_byte_pos(col)
- if col > 0 then
- local buf_line = lines[line + 1] or ''
- return util._str_byteindex_enc(buf_line, col, client.offset_encoding)
- end
- return col
- end
-
- local start_col = _get_byte_pos(start_char)
- local end_col = _get_byte_pos(start_char + data[i + 2])
+ local end_char = start_char + data[i + 2]
+ local buf_line = lines and lines[line + 1] or ''
+ local start_col = vim.str_byteindex(buf_line, client.offset_encoding, start_char, false)
+ local end_col = vim.str_byteindex(buf_line, client.offset_encoding, end_char, false)
if token_type then
ranges[#ranges + 1] = {