Skip to content

Commit 2704a97

Browse files
committed
fix menu title abbreviation
1 parent c237760 commit 2704a97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lua/dyn_menu.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,16 @@ local function utf8_sub(s, i, j)
171171
return table.concat(t)
172172
end
173173

174+
-- return the length of a utf8 string
175+
local function utf8_len(s)
176+
local _, count = s:gsub(UTF8_PATTERN, "")
177+
return count
178+
end
179+
174180
-- abbreviate title if it's too long
175181
local function abbr_title(str)
176182
if not str or str == '' then return '' end
177-
if o.max_title_length > 0 and str:len() > o.max_title_length then
183+
if o.max_title_length > 0 and utf8_len(str) > o.max_title_length then
178184
return utf8_sub(str, 1, o.max_title_length) .. '...'
179185
end
180186
return str

0 commit comments

Comments
 (0)