diff --git a/crates/vite_global_cli/src/commands/env/setup.rs b/crates/vite_global_cli/src/commands/env/setup.rs index 45718c87cf..229931775f 100644 --- a/crates/vite_global_cli/src/commands/env/setup.rs +++ b/crates/vite_global_cli/src/commands/env/setup.rs @@ -449,6 +449,7 @@ if [ -n "$BASH_VERSION" ] && type complete >/dev/null 2>&1; then eval "$(VP_COMPLETE=bash command vp)" elif [ -n "$ZSH_VERSION" ] && type compdef >/dev/null 2>&1; then eval "$(VP_COMPLETE=zsh command vp)" + eval ' _vpr_complete() { local -a orig=("${words[@]}") words=("vp" "run" "${orig[@]:1}") @@ -456,6 +457,7 @@ elif [ -n "$ZSH_VERSION" ] && type compdef >/dev/null 2>&1; then ${=_comps[vp]} } compdef _vpr_complete vpr + ' fi "# .replace("__VP_BIN__", &bin_path_ref); @@ -918,6 +920,10 @@ mod tests { env_content.contains("compdef _vpr_complete vpr"), "env should have vpr completion for zsh" ); + assert!( + env_content.contains("eval '") && env_content.contains("_vpr_complete() {"), + "env should wrap zsh-specific code in eval" + ); assert!(fish_content.contains("complete -c vpr"), "env.fish should have vpr completion"); assert!( ps1_content.contains("Register-ArgumentCompleter -Native -CommandName vpr"),