fix: partial matching

This commit is contained in:
iff 2023-08-01 20:52:17 +02:00
parent 9978c3bcab
commit 295ab1e76d

View file

@ -10,21 +10,23 @@ pub fn highlight_difference(suggested_command: &str, last_command: &str) -> Stri
if command.is_empty() {
continue;
}
'old: for old in split_last_command.clone() {
for old in split_last_command.clone() {
if command == &old {
old_entries.push(command.clone());
break 'old;
break;
}
}
}
let mut highlighted = suggested_command.to_string();
for entry in &split_suggested_command {
if old_entries.contains(entry) {
highlighted = highlighted.replace(entry, &entry.cyan().to_string());
} else {
highlighted = highlighted.replace(entry, &entry.red().bold().to_string());
'next: for entry in &split_suggested_command {
for old in &old_entries {
if old == entry {
highlighted = highlighted.replace(entry, &entry.cyan().to_string());
continue 'next;
}
}
highlighted = highlighted.replace(entry, &entry.red().bold().to_string());
}
highlighted