Skip to content

Commit cf26c4a

Browse files
committed
Auto merge of #10810 - Diomendius:bugfix-zsh-completions, r=weihanglo
Fix zsh completions for add and locate-project Currently, trying to tab-complete either the `cargo add` or `cargo locate-project` subcommands results in output such as this: ``` cargo add _cargo:67: command not found: --default-features[enable the default features] _cargo:68: command not found: --no-default-features[don't enable the default features] _cargo:69: command not found: --optional[mark the dependency as optional] ``` This is because some line continuations are missing from `src/etc/_cargo`. This PR adds these line continuations. This file gets packaged for Rust releases by https://github.com/rust-lang/rust/blob/acdcdfb61b7b472bfacbb8bb889bdf3204827f2e/src/bootstrap/dist.rs#L956 and Rustup ultimately places it in `~/.rustup/toolchains/*/share/zsh/site-functions/_cargo`. `rustup completions zsh cargo` outputs a script which sources this filepath. The easier approach to testing this is probably to manually copy `_cargo` to its proper location under `~/.rustup`, assuming Rust is already installed via Rustup and Zsh completions for Cargo are already installed, but however you choose to install this, testing is as simple as observing that Zsh can correctly tab complete `cargo add` and `cargo locate-project`.
2 parents 501b56b + f44e2b5 commit cf26c4a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/etc/_cargo

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ _cargo() {
6868
case ${words[1]} in
6969
add)
7070
_arguments -s -A "^--" $common $manifest $registry \
71-
{-F+,--features=}'[specify features to activate]:feature'
72-
"--default-features[enable the default features]"
73-
"--no-default-features[don't enable the default features]"
74-
"--optional[mark the dependency as optional]"
75-
"--no-optional[mark the dependency as required]"
76-
"--dev[add as a dev dependency]"
77-
"--build[add as a build dependency]"
78-
"--target=[add as a dependency to the given target platform]"
79-
"--rename=[rename the dependency]"
80-
"--dry-run[don't actually write the manifest]"
71+
{-F+,--features=}'[specify features to activate]:feature' \
72+
"--default-features[enable the default features]" \
73+
"--no-default-features[don't enable the default features]" \
74+
"--optional[mark the dependency as optional]" \
75+
"--no-optional[mark the dependency as required]" \
76+
"--dev[add as a dev dependency]" \
77+
"--build[add as a build dependency]" \
78+
"--target=[add as a dependency to the given target platform]" \
79+
"--rename=[rename the dependency]" \
80+
"--dry-run[don't actually write the manifest]" \
8181
'--branch=[branch to use when adding from git]:branch' \
8282
'--git=[specify URL from which to add the crate]:url:_urls' \
8383
'--path=[local filesystem path to crate to add]: :_directories' \
@@ -182,7 +182,7 @@ _cargo() {
182182

183183
locate-project)
184184
_arguments -s -S $common $manifest \
185-
'--message-format=[specify output representation]:output representation [json]:(json plain)'
185+
'--message-format=[specify output representation]:output representation [json]:(json plain)' \
186186
'--workspace[locate Cargo.toml of the workspace root]'
187187
;;
188188

0 commit comments

Comments
 (0)