aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-05-30 16:55:29 +0200
committerGitHub <noreply@github.com>2024-05-30 15:55:29 +0100
commit21109517c02c883bda9d2cfb0f15c68f2f8ebb3e (patch)
tree33f1bc6d9d46c20a3f1475c87e8f0c48a00a1899 /crates
parentchore: handle rate limited responses (#2057) (diff)
downloadatuin-21109517c02c883bda9d2cfb0f15c68f2f8ebb3e.zip
fix(stats): generation for commands starting with a pipe (#2058)
Closes #1882
Diffstat (limited to 'crates')
-rw-r--r--crates/atuin-history/src/stats.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/atuin-history/src/stats.rs b/crates/atuin-history/src/stats.rs
index ab4127df..b73a5dbb 100644
--- a/crates/atuin-history/src/stats.rs
+++ b/crates/atuin-history/src/stats.rs
@@ -92,7 +92,7 @@ fn split_at_pipe(command: &str) -> Vec<&str> {
"\\" => if graphemes.next().is_some() {},
"|" => {
if !quoted {
- if command[start..].starts_with('|') {
+ if current > start && command[start..].starts_with('|') {
start += 1;
}
result.push(&command[start..current]);
@@ -396,4 +396,20 @@ mod tests {
["git commit -m \"🚀\""]
);
}
+
+ #[test]
+ fn starts_with_pipe() {
+ assert_eq!(
+ split_at_pipe("| sed 's/[0-9a-f]//g'"),
+ ["", " sed 's/[0-9a-f]//g'"]
+ );
+ }
+
+ #[test]
+ fn starts_with_spaces_and_pipe() {
+ assert_eq!(
+ split_at_pipe(" | sed 's/[0-9a-f]//g'"),
+ [" ", " sed 's/[0-9a-f]//g'"]
+ );
+ }
}