From 304ec9ad87aa7713fc691d51ebbe0c7a7e56cb96 Mon Sep 17 00:00:00 2001 From: sudotac Date: Sun, 3 Dec 2023 17:27:00 +0900 Subject: [PATCH] fix(complete): Suppress a useless space completion --- clap_complete/src/shells/bash.rs | 1 + .../tests/snapshots/home/static/exhaustive/bash/.bashrc | 3 +++ clap_complete/tests/snapshots/value_hint.bash | 3 +++ 3 files changed, 7 insertions(+) diff --git a/clap_complete/src/shells/bash.rs b/clap_complete/src/shells/bash.rs index 4dd588984074..44ba85135a9d 100644 --- a/clap_complete/src/shells/bash.rs +++ b/clap_complete/src/shells/bash.rs @@ -167,6 +167,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, }; diff --git a/clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc b/clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc index 12275158ccdc..a46deda5c30f 100644 --- a/clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc +++ b/clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc @@ -542,6 +542,9 @@ _exhaustive() { ;; --other) COMPREPLY=("${cur}") + if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then + compopt -o nospace + fi return 0 ;; --path) diff --git a/clap_complete/tests/snapshots/value_hint.bash b/clap_complete/tests/snapshots/value_hint.bash index 1b84cf6fba83..30be1bbd3441 100644 --- a/clap_complete/tests/snapshots/value_hint.bash +++ b/clap_complete/tests/snapshots/value_hint.bash @@ -35,6 +35,9 @@ _my-app() { ;; --other) COMPREPLY=("${cur}") + if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then + compopt -o nospace + fi return 0 ;; --path)