Skip to content

Commit

Permalink
fix: offset encoding conversion on nvim 0.11.0 (#308)
Browse files Browse the repository at this point in the history
* fix: #307

* feat: use vim.fn.has to check version, fallback offset encoding

---------

Co-authored-by: Liam Dyer <[email protected]>
  • Loading branch information
Euro20179 and Saghen authored Nov 10, 2024
1 parent f65b03b commit 9822c6b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/blink/cmp/accept/text-edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ local function get_line_byte_from_position(position, offset_encoding)
-- character
if col > 0 then
local line = vim.api.nvim_buf_get_lines(bufnr, position.line, position.line + 1, true)[1] or ''
return vim.lsp.util._str_byteindex_enc(line, col, offset_encoding or 'utf-16')
if vim.fn.has('nvim-0.11.0') == 1 then
return vim.str_byteindex(line, offset_encoding or 'utf-16', col, false)
else
return vim.lsp.util._str_byteindex_enc(line, col, offset_encoding or 'utf-16')
end
end
return col
end
Expand Down

0 comments on commit 9822c6b

Please sign in to comment.