From 78b930b90c7abd1cd59981427510ba2324004060 Mon Sep 17 00:00:00 2001 From: zztrieuzz Date: Sun, 27 Oct 2024 08:11:16 +0700 Subject: [PATCH] fix: truncate function --- lua/spectre/utils.lua | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lua/spectre/utils.lua b/lua/spectre/utils.lua index 3cdf55a..308487c 100644 --- a/lua/spectre/utils.lua +++ b/lua/spectre/utils.lua @@ -57,21 +57,7 @@ M.truncate = function(str, len) if vim.api.nvim_strwidth(str) <= len then return str end - local charlen = 0 - local cur_len = 0 - local result = '' - local len_of_dots = vim.api.nvim_strwidth('…') - while true do - local part = M.strcharpart(str, charlen, 1) - cur_len = cur_len + vim.api.nvim_strwidth(part) - if (cur_len + len_of_dots) > len then - result = result .. '…' - break - end - result = result .. part - charlen = charlen + 1 - end - return result + return string.sub(str, 0, len) .. " ..." end -- only escape slash M.escape_slash = function(query)