mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
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:
@@ -70,20 +70,12 @@ function M.on_inlayhint(err, result, ctx, _)
|
||||
end
|
||||
|
||||
local lines = api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||
---@param position lsp.Position
|
||||
---@return integer
|
||||
local function pos_to_byte(position)
|
||||
local col = position.character
|
||||
if col > 0 then
|
||||
local line = lines[position.line + 1] or ''
|
||||
return util._str_byteindex_enc(line, col, client.offset_encoding)
|
||||
end
|
||||
return col
|
||||
end
|
||||
|
||||
for _, hint in ipairs(result) do
|
||||
local lnum = hint.position.line
|
||||
hint.position.character = pos_to_byte(hint.position)
|
||||
local line = lines and lines[lnum + 1] or ''
|
||||
hint.position.character =
|
||||
vim.str_byteindex(line, client.offset_encoding, hint.position.character, false)
|
||||
table.insert(new_lnum_hints[lnum], hint)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user