fixed unicode truncation bug

This commit is contained in:
Cliford 2021-10-08 19:51:35 +05:30
parent 8c5a58c93c
commit 773b371cb4

View file

@ -16,8 +16,8 @@ local GET_SPOTIFY_STATUS_CMD = 'sp status'
local GET_CURRENT_SONG_CMD = 'sp current'
local function ellipsize(text, length)
return (text:len() > length and length > 0)
and text:sub(0, length - 3) .. '...'
return (utf8.len(text) > length and length > 0)
and text:sub(0, utf8.offset(text, length - 2) - 1) .. '...'
or text
end