From 8d99ec60170f1ec9ccee97f0798eb635a40f80c6 Mon Sep 17 00:00:00 2001 From: Daniel Fleischer Date: Tue, 17 Sep 2024 22:49:52 +0300 Subject: [PATCH 1/2] zsh import line break fix Related to #1555, #98. --- crates/atuin-client/src/import/zsh.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/atuin-client/src/import/zsh.rs b/crates/atuin-client/src/import/zsh.rs index 5bc8fc16416..a51b22234aa 100644 --- a/crates/atuin-client/src/import/zsh.rs +++ b/crates/atuin-client/src/import/zsh.rs @@ -67,9 +67,16 @@ impl Importer for Zsh { _ => continue, // we can skip past things like invalid utf8 }; - if let Some(s) = s.strip_suffix('\\') { - line.push_str(s); - line.push_str("\\\n"); + if s.ends_with("\\\\") { + if let Some(s) = s.strip_suffix("\\\\") { + line.push_str(s); + line.push_str("\\\n"); + } + } else if s.ends_with('\\') { + if let Some(s) = s.strip_suffix('\\') { + line.push_str(s); + line.push_str("\\\n"); + } } else { line.push_str(&s); let command = std::mem::take(&mut line); From 42f92569870b4fdddedbd9a13e693829e13f75b5 Mon Sep 17 00:00:00 2001 From: Daniel Fleischer Date: Tue, 17 Sep 2024 23:07:00 +0300 Subject: [PATCH 2/2] Test --- crates/atuin-client/src/import/zsh.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/atuin-client/src/import/zsh.rs b/crates/atuin-client/src/import/zsh.rs index a51b22234aa..03838f55ef0 100644 --- a/crates/atuin-client/src/import/zsh.rs +++ b/crates/atuin-client/src/import/zsh.rs @@ -196,13 +196,15 @@ mod test { let bytes = r": 1613322469:0;cargo install atuin : 1613322469:10;cargo install atuin; \ cargo update +: 1613322469:10;cargo install atuin; \\ +cargo update : 1613322469:10;cargo :b̷i̶t̴r̵o̴t̴ ̵i̷s̴ ̷r̶e̵a̸l̷ " .as_bytes() .to_owned(); let mut zsh = Zsh { bytes }; - assert_eq!(zsh.entries().await.unwrap(), 4); + assert_eq!(zsh.entries().await.unwrap(), 6); let mut loader = TestLoader::default(); zsh.load(&mut loader).await.unwrap(); @@ -212,6 +214,7 @@ cargo update [ "cargo install atuin", "cargo install atuin; \\\ncargo update", + "cargo install atuin; \\\ncargo update", "cargo :b̷i̶t̴r̵o̴t̴ ̵i̷s̴ ̷r̶e̵a̸l̷", ], );