Skip to content

Commit

Permalink
fix warnings for vim.str.utfindex and str_byteindex
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtoombs committed Dec 20, 2024
1 parent 98e8b9d commit 4ed035f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/cmp/utils/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ end
---@return integer
misc.to_utfindex = function(text, vimindex)
vimindex = vimindex or #text + 1
return vim.str_utfindex(text, math.max(0, math.min(vimindex - 1, #text)))
return vim.str_utfindex(text, "utf-8", math.max(0, math.min(vimindex - 1, #text)))
end

---Safe version of vim.str_byteindex
Expand All @@ -208,7 +208,7 @@ misc.to_vimindex = function(text, utfindex)
utfindex = utfindex or #text
for i = utfindex, 1, -1 do
local s, v = pcall(function()
return vim.str_byteindex(text, i) + 1
return vim.str_byteindex(text, "utf-8", i) + 1
end)
if s then
return v
Expand Down

0 comments on commit 4ed035f

Please sign in to comment.