fix: some error handlings

This commit is contained in:
iff 2023-08-07 20:21:02 +02:00
parent 1444eeab84
commit 15c1ba3370
7 changed files with 49 additions and 37 deletions

View file

@ -4,8 +4,12 @@ use colored::*;
// to_string() is necessary here, otherwise there won't be color in the output
#[warn(clippy::unnecessary_to_owned)]
pub fn highlight_difference(shell: &str, suggested_command: &str, last_command: &str) -> Option<String> {
let replaced_newline = suggested_command.replace("\n", r" {{newline}}");
pub fn highlight_difference(
shell: &str,
suggested_command: &str,
last_command: &str,
) -> Option<String> {
let replaced_newline = suggested_command.replace('\n', r" {{newline}}");
let mut split_suggested_command = split_command(&replaced_newline);
let split_last_command = split_command(last_command);
@ -31,7 +35,7 @@ pub fn highlight_difference(shell: &str, suggested_command: &str, last_command:
// let mut highlighted = suggested_command.to_string();
'next: for entry in split_suggested_command.iter_mut() {
if entry == r"{{newline}" {
continue
continue;
}
for old in &old_entries {
if old == entry {