mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 22:40:09 +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() {
|
if command.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
'old: for old in split_last_command.clone() {
|
for old in split_last_command.clone() {
|
||||||
if command == &old {
|
if command == &old {
|
||||||
old_entries.push(command.clone());
|
old_entries.push(command.clone());
|
||||||
break 'old;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut highlighted = suggested_command.to_string();
|
let mut highlighted = suggested_command.to_string();
|
||||||
for entry in &split_suggested_command {
|
'next: for entry in &split_suggested_command {
|
||||||
if old_entries.contains(entry) {
|
for old in &old_entries {
|
||||||
highlighted = highlighted.replace(entry, &entry.cyan().to_string());
|
if old == entry {
|
||||||
} else {
|
highlighted = highlighted.replace(entry, &entry.cyan().to_string());
|
||||||
highlighted = highlighted.replace(entry, &entry.red().bold().to_string());
|
continue 'next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
highlighted = highlighted.replace(entry, &entry.red().bold().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
highlighted
|
highlighted
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue