Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22bf919

Browse files
committed
fix(complete): Suppress a useless space completion
We cannot add tests for this because white spaces are trimmed by runtime.complete().
1 parent 2f75e2d commit 22bf919

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

clap_complete/src/shells/bash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ fn option_details_for_path(cmd: &Command, path: &str) -> String {
171171
let compopt = match o.get_value_hint() {
172172
ValueHint::FilePath => Some("compopt -o filenames"),
173173
ValueHint::DirPath => Some("compopt -o plusdirs"),
174+
ValueHint::Other => Some("compopt -o nospace"),
174175
_ => None,
175176
};
176177

clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ _exhaustive() {
542542
;;
543543
--other)
544544
COMPREPLY=("${cur}")
545+
if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
546+
compopt -o nospace
547+
fi
545548
return 0
546549
;;
547550
--path)

clap_complete/tests/snapshots/value_hint.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ _my-app() {
3535
;;
3636
--other)
3737
COMPREPLY=("${cur}")
38+
if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
39+
compopt -o nospace
40+
fi
3841
return 0
3942
;;
4043
--path)

0 commit comments

Comments
 (0)