|
|
@ -3074,11 +3074,19 @@ fn command_mode(cx: &mut Context) {
|
|
|
|
// simple heuristic: if there's no just one part, complete command name.
|
|
|
|
// simple heuristic: if there's no just one part, complete command name.
|
|
|
|
// if there's a space, per command completion kicks in.
|
|
|
|
// if there's a space, per command completion kicks in.
|
|
|
|
if parts.len() <= 1 {
|
|
|
|
if parts.len() <= 1 {
|
|
|
|
let end = 0..;
|
|
|
|
let mut matches: Vec<_> = cmd::TYPABLE_COMMAND_LIST
|
|
|
|
cmd::TYPABLE_COMMAND_LIST
|
|
|
|
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.filter(|command| FUZZY_MATCHER.fuzzy_match(command.name, input).is_some())
|
|
|
|
.filter_map(|command| {
|
|
|
|
.map(|command| (end.clone(), Cow::Borrowed(command.name)))
|
|
|
|
FUZZY_MATCHER
|
|
|
|
|
|
|
|
.fuzzy_match(command.name, input)
|
|
|
|
|
|
|
|
.map(|score| (command.name, score))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matches.sort_unstable_by_key(|(_file, score)| std::cmp::Reverse(*score));
|
|
|
|
|
|
|
|
matches
|
|
|
|
|
|
|
|
.into_iter()
|
|
|
|
|
|
|
|
.map(|(name, _)| (0.., name.into()))
|
|
|
|
.collect()
|
|
|
|
.collect()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let part = parts.last().unwrap();
|
|
|
|
let part = parts.last().unwrap();
|
|
|
|