Skip to content

Commit

Permalink
fix: completions with descriptions splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 18, 2024
1 parent c833bb4 commit 5e72f3b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cli/src/cli/complete_word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,18 @@ impl CompleteWord {
.filter(|l| l.starts_with(ctoken))
.map(|l| {
if complete.descriptions {
match re.splitn(l, 2).collect::<Vec<_>>().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());
Expand Down

0 comments on commit 5e72f3b

Please sign in to comment.