don't use deprecated functions
This commit is contained in:
@@ -197,7 +197,7 @@ end
|
|||||||
---@return integer
|
---@return integer
|
||||||
misc.to_utfindex = function(text, vimindex)
|
misc.to_utfindex = function(text, vimindex)
|
||||||
vimindex = vimindex or #text + 1
|
vimindex = vimindex or #text + 1
|
||||||
return vim.str_utfindex(text, math.max(0, math.min(vimindex - 1, #text)))
|
return vim.str_utfindex(text, 'utf-16', math.max(0, math.min(vimindex - 1, #text)))
|
||||||
end
|
end
|
||||||
|
|
||||||
---Safe version of vim.str_byteindex
|
---Safe version of vim.str_byteindex
|
||||||
@@ -208,7 +208,7 @@ misc.to_vimindex = function(text, utfindex)
|
|||||||
utfindex = utfindex or #text
|
utfindex = utfindex or #text
|
||||||
for i = utfindex, 1, -1 do
|
for i = utfindex, 1, -1 do
|
||||||
local s, v = pcall(function()
|
local s, v = pcall(function()
|
||||||
return vim.str_byteindex(text, i) + 1
|
return vim.str_byteindex(text, 'utf-16', i) + 1
|
||||||
end)
|
end)
|
||||||
if s then
|
if s then
|
||||||
return v
|
return v
|
||||||
|
|||||||
Reference in New Issue
Block a user