Skip to content

Commit

Permalink
refactor(command_not_found): remove repetetive fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed Aug 17, 2024
1 parent 9457a1c commit ea116b8
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/rules/command_not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ fn command_not_found_impl(
.filter_map(|dir_entry_res| dir_entry_res.ok())
.filter_map(|dir_entry| canonicalize(dir_entry.path()).ok())
.filter(|path| path.is_file())
.filter_map(|path| {
let f = path.file_name()?;
let f = f.to_str()?;
.filter_map(|path| path.file_name()?.to_str().map(String::from))
.chain(shell_items)
.map(|fix| {
let mut r = cmd.clone();
r[idx] = f.to_string();
Some(r)
})
.chain(shell_items.into_iter().map(|item| {
let mut r = cmd.clone();
r[idx] = item;
r[idx] = fix;
r
}))
})
.collect()
}

Expand Down

0 comments on commit ea116b8

Please sign in to comment.