From f43282499524f54837959c30a94f440e0fde0ecd Mon Sep 17 00:00:00 2001 From: Michael Baikov Date: Fri, 16 Aug 2024 09:39:42 -0400 Subject: [PATCH] don't call disambiguation check when doing completion --- src/info.rs | 10 +++++++++- tests/completion.rs | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) 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]