Skip to content

Commit 244578e

Browse files
committed
fix(complete): Don't complete files for any value
We now need to opt-in to path completions for values, which can be as simple as setting the value parser to be for `PathBuf`s. We'll now show a lot less irrelevant completions.
1 parent 2e309bd commit 244578e

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cargo-util = { version = "0.2.14", path = "crates/cargo-util" }
3636
cargo-util-schemas = { version = "0.7.0", path = "crates/cargo-util-schemas" }
3737
cargo_metadata = "0.18.1"
3838
clap = "4.5.18"
39-
clap_complete = { version = "4.5.29", features = ["unstable-dynamic"] }
39+
clap_complete = { version = "4.5.32", features = ["unstable-dynamic"] }
4040
color-print = "0.3.6"
4141
core-foundation = { version = "0.10.0", features = ["mac_os_10_7_support"] }
4242
crates-io = { version = "0.40.4", path = "crates/crates-io" }

src/bin/cargo/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ fn main() {
3434
let _span = tracing::span!(tracing::Level::TRACE, "completions").entered();
3535
let args = std::env::args_os();
3636
let current_dir = std::env::current_dir().ok();
37-
let completer =
38-
clap_complete::CompleteEnv::with_factory(|| cli::cli(&mut gctx)).var("CARGO_COMPLETE");
37+
let completer = clap_complete::CompleteEnv::with_factory(|| {
38+
let mut gctx = GlobalContext::default().expect("already loaded without errors");
39+
cli::cli(&mut gctx)
40+
})
41+
.var("CARGO_COMPLETE");
3942
if completer
4043
.try_complete(args, current_dir.as_deref())
4144
.unwrap_or_else(|e| {

0 commit comments

Comments
 (0)