File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ local state = g.state
1111local style = g .style
1212local ass = g .ass
1313
14+ --- https://www.unicode.org/reports/tr9/#Explicit_Directional_Isolates
15+ local ISOLATE_DIRECTION_START = ' \226\129\168 ' -- U+2068 FIRST STRONG ISOLATE
16+ local ISOLATE_DIRECTION_END = ' \226\129\169 ' -- U+2069 POP DIRECTIONAL ISOLATE
17+
1418local function draw ()
1519 ass :update ()
1620end
@@ -59,6 +63,15 @@ local function highlight_entry(v)
5963 end
6064end
6165
66+ --- Escapes unwanted unicode control characters that may affect the rest of the display.
67+ --- Currently this only isolates unicode directional overrides.
68+ --- Based on: https://github.com/mpv-player/mpv/pull/17606
69+ --- @param str string
70+ --- @return string
71+ local function unicode_escape (str )
72+ return ISOLATE_DIRECTION_START .. str .. ISOLATE_DIRECTION_END
73+ end
74+
6275--- escape ass values and replace newlines
6376--- @param str string
6477--- @param style_reset string ?
@@ -203,7 +216,7 @@ local function update_ass()
203216 end
204217
205218 -- adds the actual name of the item
206- append (v .ass or ass_escape (v .label or v .name , item_style ), ' \\ h' )
219+ append (v .ass or ass_escape ( unicode_escape ( v .label or v .name ) , item_style ), ' \\ h' )
207220 if g .ALIGN_X == ' right' then draw_cursor (i , o .cursor_icon_flipped ) end
208221 newline ()
209222 end
You can’t perform that action at this time.
0 commit comments