From 4ed035ffb9e413c18210d4713d0a0deac36b75b2 Mon Sep 17 00:00:00 2001 From: jdtoombs Date: Thu, 19 Dec 2024 18:35:50 -0800 Subject: [PATCH] fix warnings for vim.str.utfindex and str_byteindex --- lua/cmp/utils/misc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/cmp/utils/misc.lua b/lua/cmp/utils/misc.lua index fbd7de1fe..363530744 100644 --- a/lua/cmp/utils/misc.lua +++ b/lua/cmp/utils/misc.lua @@ -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 @@ -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