Skip to content

Commit

Permalink
fix(complete): Suppress a useless space completion
Browse files Browse the repository at this point in the history
We cannot add tests for this because white spaces are trimmed by
runtime.complete().
  • Loading branch information
sudotac committed Jan 4, 2024
1 parent 2f75e2d commit 22bf919
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
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]:-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]:-0}" -ge 4 ]; then
compopt -o nospace
fi
return 0
;;
--path)
Expand Down

0 comments on commit 22bf919

Please sign in to comment.