-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
A-completionArea: completion generatorArea: completion generatorC-bugCategory: bugCategory: bugE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mediumCall for participation: Experience needed to fix: Medium / intermediateCall for participation: Experience needed to fix: Medium / intermediate
Description
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Rust Version
rustc 1.91.0 (f8297e351 2025-10-28)
Clap Version
clap 4.5.51, clap_complete 4.5.60
Minimal reproducible code
use std::path::PathBuf;
use clap::{CommandFactory, Parser, ValueHint};
use clap_complete::CompleteEnv;
#[derive(Parser, Debug, PartialEq)]
#[command(name = "mycomp")]
struct Opt {
#[arg(value_hint = ValueHint::FilePath)]
file: PathBuf,
}
fn main() {
CompleteEnv::with_factory(|| Opt::command()).complete();
let opt = Opt::parse();
println!("{:#?}", opt.file);
}Steps to reproduce the bug with the above code
If the binary is called mycomp, then in zsh (not bash!):
source <(COMPLETE=zsh mycomp)Then assume your current folder looks like
. -
+- sub1
+- sub2
Then using completion like
mycomp <TAB>
Actual Behaviour
You get
mycomp sub1/<SPACE>
so pressing tab again will not show sub2. In bash the behavior is correct (not adding space here).
Expected Behaviour
If there are still files or sub folders available for completion, no space should be added (same as in bash).
Additional Context
Based on discussion in #6176
Debug Output
No response
Metadata
Metadata
Assignees
Labels
A-completionArea: completion generatorArea: completion generatorC-bugCategory: bugCategory: bugE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mediumCall for participation: Experience needed to fix: Medium / intermediateCall for participation: Experience needed to fix: Medium / intermediate