diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-02-14 09:45:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-14 09:45:55 +0000 |
| commit | 1f7d3a34e76c9ce01a7b0374b9577f9b20314774 (patch) | |
| tree | 17a2089008f5b51c31542aa8d2bc30e12468ee09 /src/command/client | |
| parent | Add `history_filter` cfg to exclude commands from history (#515) (#716) (diff) | |
| download | atuin-1f7d3a34e76c9ce01a7b0374b9577f9b20314774.zip | |
Check before unwrapping in stats (#717)
Should fix the error @pdecat found!
Diffstat (limited to '')
| -rw-r--r-- | src/command/client/stats.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/command/client/stats.rs b/src/command/client/stats.rs index b6634233..45bc3571 100644 --- a/src/command/client/stats.rs +++ b/src/command/client/stats.rs @@ -26,9 +26,13 @@ pub struct Cmd { fn compute_stats(history: &[History], count: usize) -> Result<()> { let mut commands = HashMap::<&str, usize>::new(); for i in history { - *commands - .entry(i.command.split_ascii_whitespace().next().unwrap()) - .or_default() += 1; + let command = i.command.split_ascii_whitespace().next(); + + if command.is_none() { + continue; + } + + *commands.entry(command.unwrap()).or_default() += 1; } let unique = commands.len(); let mut top = commands.into_iter().collect::<Vec<_>>(); |
