Commit 586e401f authored by Daniel García Moreno's avatar Daniel García Moreno

Fix autocomplete crash with unicode usernames

Sometimes, when we try to autocomplete with usernames with unicodes, the
count of chars is different from the count of graphemes so we were
trying to split the list of graphemes at a out of bound position.

Making the check first and returning if it's not possible fixs the

Fix #202
parent f1dacf00
......@@ -197,6 +197,11 @@ impl Autocomplete {
let pos = e.get_position();
if let Some(text) = text.clone() {
let graphs = UnicodeSegmentation::graphemes(text.as_str(), true).collect::<Vec<&str>>();
if pos as usize > graphs.len() {
return Inhibit(false);
let (p1, _) = graphs.split_at(pos as usize);
let first = p1.join("");
if own.borrow().popover_position.is_none() {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment