Skip to content

Commit 9822c6b

Browse files
Euro20179Saghen
andauthored
fix: offset encoding conversion on nvim 0.11.0 (#308)
* fix: #307 * feat: use vim.fn.has to check version, fallback offset encoding --------- Co-authored-by: Liam Dyer <[email protected]>
1 parent f65b03b commit 9822c6b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lua/blink/cmp/accept/text-edits.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ local function get_line_byte_from_position(position, offset_encoding)
4646
-- character
4747
if col > 0 then
4848
local line = vim.api.nvim_buf_get_lines(bufnr, position.line, position.line + 1, true)[1] or ''
49-
return vim.lsp.util._str_byteindex_enc(line, col, offset_encoding or 'utf-16')
49+
if vim.fn.has('nvim-0.11.0') == 1 then
50+
return vim.str_byteindex(line, offset_encoding or 'utf-16', col, false)
51+
else
52+
return vim.lsp.util._str_byteindex_enc(line, col, offset_encoding or 'utf-16')
53+
end
5054
end
5155
return col
5256
end

0 commit comments

Comments
 (0)