-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(shell/zsh.rs): avoid hook-env execution on Enter without command (…
…#2861) * perf(shell/zsh.rs): avoid hook-env execution on Enter without command Some zsh configuration are intentionally optimized to work really fast and it's important to keep it feels this way. And while `mise hook-env` is really fast (0.008 sec on my system) and slowdown isn't noticeable when running any command (even builtin one like `echo` or `true`) it still result in _noticeable_ slowdown when just pressing Enter without any command. At a glance proposed optimization shouldn't break any functionality, and it fixes mentioned above noticeable slowdown. * fix(shell/zsh.rs): always trigger hook on cd Fixes an issue when directory is changed after empty command (just Enter) using keyboard shortcut (e.g. Ctrl-PgUp/Down) instead of `cd` command - in this case hook wasn't triggered which result in showing other project's env variables to first command executed in non-project dir. * fix(shell/zsh.rs): ensure hook-env will run on zsh start This fixes two cases: - Optimization bug: first command in a new shell won't get right env. - Adds support for `zsh -i -c '...'` which also won't get right env. * fix(shell/zsh.rs): deactivate _mise_hook_cmd * fix(shell/zsh.rs): deactivate precmd_functions * test: updated snapshots --------- Co-authored-by: jdx <[email protected]>
- Loading branch information
Showing
4 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
--- | ||
source: src/cli/deactivate.rs | ||
expression: output | ||
snapshot_kind: text | ||
--- | ||
export PATH='$PATH' | ||
precmd_functions=( ${precmd_functions:#_mise_hook} ) | ||
precmd_functions=( ${precmd_functions:#_mise_hook_cmd} ) | ||
chpwd_functions=( ${chpwd_functions:#_mise_hook} ) | ||
unset -f _mise_hook_cmd | ||
unset -f _mise_hook | ||
unset -f mise | ||
unset MISE_SHELL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
--- | ||
source: src/shell/zsh.rs | ||
expression: replace_path(&deactivate) | ||
snapshot_kind: text | ||
--- | ||
precmd_functions=( ${precmd_functions:#_mise_hook} ) | ||
precmd_functions=( ${precmd_functions:#_mise_hook_cmd} ) | ||
chpwd_functions=( ${chpwd_functions:#_mise_hook} ) | ||
unset -f _mise_hook_cmd | ||
unset -f _mise_hook | ||
unset -f mise | ||
unset MISE_SHELL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters