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)
This commit is contained in:
Tristan Knight
2024-10-26 15:38:25 +01:00
committed by GitHub
parent b922b7d6d7
commit 25b53b593e
12 changed files with 54 additions and 176 deletions

View File

@ -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] = {