Skip to content

Commit

Permalink
fix: truncate function
Browse files Browse the repository at this point in the history
  • Loading branch information
zztrieuzz committed Oct 27, 2024
1 parent ba7fb77 commit 78b930b
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions lua/spectre/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 78b930b

Please sign in to comment.