From e2c4645aeb8db7952ecce84b571da7c53df18f12 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Thu, 15 Jul 2021 15:34:28 +0200 Subject: [PATCH] Workaround for rofi's image escape sequences (bug #4) --- src/util.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util.rs b/src/util.rs index 003ca72..4715a69 100644 --- a/src/util.rs +++ b/src/util.rs @@ -240,6 +240,16 @@ where for c in choices { let s = c.format_for_display(&cfg); strs.push(s.clone()); + + // Workaround: rofi has "\u0000icon\u001f/path/to/icon.png" as image + // escape sequence which comes after the actual text but returns only + // the text, not the escape sequence. + if s.contains('\0') { + if let Some(prefix) = s.split('\0').next() { + map.insert(prefix.to_string(), c); + } + } + map.insert(s, c); }