diff --git a/helix-core/src/shellwords.rs b/helix-core/src/shellwords.rs index 44c7a48a2a50..641991ef2195 100644 --- a/helix-core/src/shellwords.rs +++ b/helix-core/src/shellwords.rs @@ -976,6 +976,25 @@ mod test { assert_eq!(Some("ENV_PATH"), args.get_flag::<&str>("env").unwrap()); } + #[test] + fn should_error_on_unknown_flag() { + let shellwords = Shellwords::from(":w --foo"); + let args = Args::from_signature( + shellwords.args(), + ParseMode::Parameters, + &[Flag { + long: "no-format", + short: None, + desc: "test", + accepts: None, + completer: None, + }], + ); + + assert_eq!(":w", shellwords.command()); + assert!(args.is_err()); + } + #[test] fn should_split_args_no_slash_unescaping() { let input = r#"single_word twó wörds \\three\ \"with\ escaping\\"#;