From 5e72f3bcda74b3b05a0b3362cfc7a39a15c53146 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:56:54 -0600 Subject: [PATCH] fix: completions with descriptions splitting --- cli/src/cli/complete_word.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cli/src/cli/complete_word.rs b/cli/src/cli/complete_word.rs index 36d2294..9cb7441 100644 --- a/cli/src/cli/complete_word.rs +++ b/cli/src/cli/complete_word.rs @@ -224,13 +224,18 @@ impl CompleteWord { .filter(|l| l.starts_with(ctoken)) .map(|l| { if complete.descriptions { - match re.splitn(l, 2).collect::>().as_slice() { - [c, d] => (c.replace("\\:", ":"), d.to_string()), - [c] => (c.replace("\\:", ":"), String::new()), - _ => unreachable!(), + match re.find(l).map(|m| l.split_at(m.end() - 1)) { + Some((l, d)) if d.len() <= 1 => { + (l.trim().replace("\\:", ":"), String::new()) + } + Some((l, d)) => ( + l.trim().replace("\\:", ":"), + d[1..].trim().replace("\\:", ":"), + ), + None => (l.trim().replace("\\:", ":"), String::new()), } } else { - (l.to_string(), String::new()) + (l.trim().to_string(), String::new()) } }) .collect());