Skip to content

Commit

Permalink
fix(complete): Suppress a useless space completion
Browse files Browse the repository at this point in the history
  • Loading branch information
sudotac committed Jan 20, 2024
1 parent e25b1ab commit 13a7980
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions clap_complete/src/shells/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ fn option_details_for_path(cmd: &Command, path: &str) -> String {
let compopt = match o.get_value_hint() {
ValueHint::FilePath => Some("compopt -o filenames"),
ValueHint::DirPath => Some("compopt -o plusdirs"),
ValueHint::Other => Some("compopt -o nospace"),
_ => None,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ _exhaustive() {
;;
--other)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--path)
Expand Down
3 changes: 3 additions & 0 deletions clap_complete/tests/snapshots/value_hint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ _my-app() {
;;
--other)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--path)
Expand Down
2 changes: 1 addition & 1 deletion clap_complete/tests/testsuite/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn complete() {
}

let input = "exhaustive hint --other \t";
let expected = "exhaustive hint --other % exhaustive hint --other ";
let expected = "exhaustive hint --other % exhaustive hint --other ";
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
}
Expand Down

0 comments on commit 13a7980

Please sign in to comment.