From 1284527fac27e82ba112651349f57227331ac055 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 16 May 2026 21:31:36 +0800 Subject: [PATCH] Path component movement to skip all escaped characters Extend the hack added in ebc140a3ea9 (Hack path component movement to skip escaped spaces, 2025-12-16) to apply to all characters, such as ";" that may be part of a file name. --- src/reader/word_motion.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/reader/word_motion.rs b/src/reader/word_motion.rs index 68c3bd070..defcaac2d 100644 --- a/src/reader/word_motion.rs +++ b/src/reader/word_motion.rs @@ -243,7 +243,7 @@ fn path_component_state_transition( use PathComponentTransition as T; ControlFlow::Continue(if is_blank(c) && !escaped { T::Blank - } else if is_path_component_character(c) || (is_blank(c) && escaped) { + } else if escaped || is_path_component_character(c) { T::PathComponent } else { T::Punctuation @@ -438,7 +438,7 @@ macro_rules! validate { } assert!( stops.is_empty(), - "expected to stop at {stops:?} but not. String: {command:?}" + "expected to stop at {stops:?} but did not. String: {command:?}" ); } } @@ -459,7 +459,8 @@ macro_rules! validate { validate!(Left, PathComponents, "^aa^@@ ^aa@@^a^"); validate!(Left, PathComponents, r#"^a\ ^b\ c/^d"^e\ f"^g"#); validate!(Left, PathComponents, r#"^a\ ^b\ c/^d"^e\\\ f"^g"#); - validate!(Left, PathComponents, r#"^a\"^bc^"#); + validate!(Left, PathComponents, r#"^a\;b^"#); + validate!(Left, PathComponents, r#"^a\"bc^"#); validate!(Right, PathComponents, "^/^foo/^bar/^baz/^"); validate!(Right, PathComponents, "^echo ^--foo ^--bar^");