From 78b1ff0d143bde94c776f2e33da19539adbcaeb6 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 | 1 + clap_complete/tests/snapshots/value_hint.bash | 1 + 3 files changed, 3 insertions(+) diff --git a/clap_complete/src/shells/bash.rs b/clap_complete/src/shells/bash.rs index 4a0f67559d8f..acaf001bb927 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 51ecc0a2669c..00570448651d 100644 --- a/clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc +++ b/clap_complete/tests/snapshots/home/static/exhaustive/bash/.bashrc @@ -542,6 +542,7 @@ _exhaustive() { ;; --other) COMPREPLY=("${cur}") + compopt -o nospace return 0 ;; --path) diff --git a/clap_complete/tests/snapshots/value_hint.bash b/clap_complete/tests/snapshots/value_hint.bash index dcd30cd9ed7a..23c5f32ac6fb 100644 --- a/clap_complete/tests/snapshots/value_hint.bash +++ b/clap_complete/tests/snapshots/value_hint.bash @@ -35,6 +35,7 @@ _my-app() { ;; --other) COMPREPLY=("${cur}") + compopt -o nospace return 0 ;; --path)