Skip to content

Commit

Permalink
fix(complete): Only return imidiate child subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
ModProg committed Jul 28, 2023
1 parent e480dda commit a087baa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clap_complete/src/dynamic/completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn complete_subcommand(value: &str, cmd: &clap::Command) -> Vec<OsString> {
value
);

let mut scs = crate::generator::utils::all_subcommands(cmd)
let mut scs = crate::generator::utils::subcommands(cmd)
.into_iter()
.filter(|x| x.0.starts_with(value))
.map(|x| OsString::from(&x.0))
Expand Down
7 changes: 3 additions & 4 deletions clap_complete/tests/testsuite/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ fn complete_dynamic() {

let input = "test-dynamic \t";
let expected = r#"% test-dynamic
action cmd-brackets complete one value --help
alias cmd-double-quotes help pacman -h --version
cmd-backslash cmd-expansions hint quote -V
cmd-backticks cmd-single-quotes last two --global"#;
action help pacman -h --help
alias hint quote -V --version
complete last value --global"#;
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
}

0 comments on commit a087baa

Please sign in to comment.