Skip to content

Commit

Permalink
don't call disambiguation check when doing completion
Browse files Browse the repository at this point in the history
  • Loading branch information
pacak committed Aug 16, 2024
1 parent d836b8c commit f432824
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,15 @@ impl<T> OptionParser<T> {

// 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)
Expand Down
4 changes: 3 additions & 1 deletion tests/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,10 +1113,12 @@ fn ambiguity_no_resolve() {
let a1 = short('a').argument::<usize>("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]
Expand Down

0 comments on commit f432824

Please sign in to comment.