Skip to content

Commit

Permalink
Revert "perf(shell/zsh.rs): avoid hook-env execution on Enter without…
Browse files Browse the repository at this point in the history
… command (#2861)"

This reverts commit a1cdc4b.
  • Loading branch information
jdx committed Nov 6, 2024
1 parent acc674b commit 7e19251
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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
10 changes: 2 additions & 8 deletions src/shell/snapshots/mise__shell__zsh__tests__activate.snap
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap
Original file line number Diff line number Diff line change
@@ -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
12 changes: 3 additions & 9 deletions src/shell/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7e19251

Please sign in to comment.