From d3bb52d7d825f2a6ce2e1c76ca472b05c6f27b40 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 5 Jan 2022 09:10:32 +0100 Subject: style: declare globals properly By default, `typeset` defines variables locally unless in the main scope. This is specially bad when using `omz plugin load`, which happens inside a function, so the declared variables don't continue being defined when the function finishes and the main scope reappears. --- plugins/rust/rust.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/rust') diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh index 014c73b3b..465b701b0 100644 --- a/plugins/rust/rust.plugin.zsh +++ b/plugins/rust/rust.plugin.zsh @@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # bind it to `cargo`. Otherwise, compinit will have already done that if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then autoload -Uz _cargo - declare -A _comps + typeset -g -A _comps _comps[cargo]=_cargo fi @@ -19,7 +19,7 @@ fi # bind it to `rustup`. Otherwise, compinit will have already done that if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then autoload -Uz _rustup - declare -A _comps + typeset -g -A _comps _comps[rustup]=_rustup fi -- cgit v1.2.3-70-g09d2 From c6e7f8905fb61b927f12f43fb57f8c514cd48a67 Mon Sep 17 00:00:00 2001 From: Joey Territo <54502648+jtt9340@users.noreply.github.com> Date: Sat, 8 Jan 2022 14:03:32 -0500 Subject: fix(rust): fix `cargo` completion when sysroot contains spaces (#10571) When generating completions for Cargo, if the Rust sysroot (i.e. `rustc +${${(z)$(rustup default)}[1]} --print sysroot`) contains spaces, Cargo completions will not work because the spaces are not escaped, thus passing two arguments to the "source" command instead of one. The spaces need to be escaped for this to work. --- plugins/rust/rust.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/rust') diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh index 465b701b0..db6ca9e74 100644 --- a/plugins/rust/rust.plugin.zsh +++ b/plugins/rust/rust.plugin.zsh @@ -27,5 +27,5 @@ fi rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &| cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF' #compdef cargo -source $(rustc +${${(z)$(rustup default)}[1]} --print sysroot)/share/zsh/site-functions/_cargo +source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo EOF -- cgit v1.2.3-70-g09d2