mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
fix: partial matching
This commit is contained in:
parent
9978c3bcab
commit
295ab1e76d
1 changed files with 9 additions and 7 deletions
16
src/style.rs
16
src/style.rs
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue