From 7e1925188eff61a4d93657d15c23bef4b5c55424 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Wed, 6 Nov 2024 05:43:17 -0600 Subject: [PATCH] Revert "perf(shell/zsh.rs): avoid hook-env execution on Enter without command (#2861)" This reverts commit a1cdc4ba40c3f0112a3566bca0273e7c4c3f3b6d. --- .../mise__cli__deactivate__tests__deactivate-2.snap | 4 +--- .../snapshots/mise__shell__zsh__tests__activate.snap | 10 ++-------- .../mise__shell__zsh__tests__deactivate.snap | 4 +--- src/shell/zsh.rs | 12 +++--------- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap b/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap index 80a78dfa6..ac9a1130d 100644 --- a/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap +++ b/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap @@ -1,12 +1,10 @@ --- source: src/cli/deactivate.rs expression: output -snapshot_kind: text --- export PATH='$PATH' -precmd_functions=( ${precmd_functions:#_mise_hook_cmd} ) +precmd_functions=( ${precmd_functions:#_mise_hook} ) chpwd_functions=( ${chpwd_functions:#_mise_hook} ) -unset -f _mise_hook_cmd unset -f _mise_hook unset -f mise unset MISE_SHELL diff --git a/src/shell/snapshots/mise__shell__zsh__tests__activate.snap b/src/shell/snapshots/mise__shell__zsh__tests__activate.snap index ad57a0a06..519352327 100644 --- a/src/shell/snapshots/mise__shell__zsh__tests__activate.snap +++ b/src/shell/snapshots/mise__shell__zsh__tests__activate.snap @@ -1,7 +1,6 @@ --- source: src/shell/zsh.rs expression: "zsh.activate(exe, \" --status\".into())" -snapshot_kind: text --- export MISE_SHELL=zsh export __MISE_ORIG_PATH="$PATH" @@ -30,14 +29,9 @@ mise() { _mise_hook() { eval "$(/some/dir/mise hook-env --status -s zsh)"; } -_mise_hook_cmd() { - if [[ -n "$ZLAST_COMMANDS" ]]; then - _mise_hook; - fi -} typeset -ag precmd_functions; -if [[ -z "${precmd_functions[(r)_mise_hook_cmd]+1}" ]]; then - precmd_functions=( _mise_hook_cmd ${precmd_functions[@]} ) +if [[ -z "${precmd_functions[(r)_mise_hook]+1}" ]]; then + precmd_functions=( _mise_hook ${precmd_functions[@]} ) fi typeset -ag chpwd_functions; if [[ -z "${chpwd_functions[(r)_mise_hook]+1}" ]]; then diff --git a/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap b/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap index bdb7d2b79..65c266ee7 100644 --- a/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap @@ -1,11 +1,9 @@ --- source: src/shell/zsh.rs expression: replace_path(&deactivate) -snapshot_kind: text --- -precmd_functions=( ${precmd_functions:#_mise_hook_cmd} ) +precmd_functions=( ${precmd_functions:#_mise_hook} ) chpwd_functions=( ${chpwd_functions:#_mise_hook} ) -unset -f _mise_hook_cmd unset -f _mise_hook unset -f mise unset MISE_SHELL diff --git a/src/shell/zsh.rs b/src/shell/zsh.rs index 1952b0e3e..bce0c6772 100644 --- a/src/shell/zsh.rs +++ b/src/shell/zsh.rs @@ -44,14 +44,9 @@ impl Shell for Zsh { _mise_hook() {{ eval "$({exe} hook-env{flags} -s zsh)"; }} - _mise_hook_cmd() {{ - if [[ -n "$ZLAST_COMMANDS" ]]; then - _mise_hook; - fi - }} typeset -ag precmd_functions; - if [[ -z "${{precmd_functions[(r)_mise_hook_cmd]+1}}" ]]; then - precmd_functions=( _mise_hook_cmd ${{precmd_functions[@]}} ) + if [[ -z "${{precmd_functions[(r)_mise_hook]+1}}" ]]; then + precmd_functions=( _mise_hook ${{precmd_functions[@]}} ) fi typeset -ag chpwd_functions; if [[ -z "${{chpwd_functions[(r)_mise_hook]+1}}" ]]; then @@ -85,9 +80,8 @@ impl Shell for Zsh { fn deactivate(&self) -> String { formatdoc! {r#" - precmd_functions=( ${{precmd_functions:#_mise_hook_cmd}} ) + precmd_functions=( ${{precmd_functions:#_mise_hook}} ) chpwd_functions=( ${{chpwd_functions:#_mise_hook}} ) - unset -f _mise_hook_cmd unset -f _mise_hook unset -f mise unset MISE_SHELL