diff options
author | Tristan Knight <admin@snappeh.com> | 2024-10-26 15:38:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-26 07:38:25 -0700 |
commit | 25b53b593ef6f229fbec5b3dc205a7539579d13a (patch) | |
tree | 8c13b6b78e22437b8fd22ac8b639ecc65417fff3 /runtime/lua/vim/lsp/inlay_hint.lua | |
parent | b922b7d6d7889cce863540df7b0da7d512f8a2a1 (diff) | |
download | rneovim-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/inlay_hint.lua')
-rw-r--r-- | runtime/lua/vim/lsp/inlay_hint.lua | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/runtime/lua/vim/lsp/inlay_hint.lua b/runtime/lua/vim/lsp/inlay_hint.lua index 61d119e653..e5892928cf 100644 --- a/runtime/lua/vim/lsp/inlay_hint.lua +++ b/runtime/lua/vim/lsp/inlay_hint.lua @@ -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 |