diff --git a/src/info.rs b/src/info.rs index a90922e6..da190f6f 100644 --- a/src/info.rs +++ b/src/info.rs @@ -212,7 +212,15 @@ impl OptionParser { // this only handles disambiguation failure in construct if let Some(msg) = err { - return Err(msg.render(&state, &self.inner.meta())); + #[cfg(feature = "autocomplete")] + let check_disambiguation = state.comp_ref().is_none(); + + #[cfg(not(feature = "autocomplete"))] + let check_disambiguation = false; + + if check_disambiguation { + return Err(msg.render(&state, &self.inner.meta())); + } } self.run_subparser(&mut state) diff --git a/tests/completion.rs b/tests/completion.rs index cee50250..04d42248 100644 --- a/tests/completion.rs +++ b/tests/completion.rs @@ -1113,10 +1113,12 @@ fn ambiguity_no_resolve() { let a1 = short('a').argument::("AAAAAA"); let parser = construct!([a0, a1]).to_options(); - parser + let r = parser .run_inner(Args::from(&["-aaa"]).set_comp(0)) .unwrap_err() .unwrap_stdout(); + + assert_eq!(r, "-aaa\n"); } #[test]