mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-11-20 16:22:52 +03:00
[readme] zsh load-nvmrc: skip during tab completion
When completing a path containing `../` for `cd`, `pushd`, or `chdir`,
zsh's `_cd` runs `$(cd ${PREFIX%/*} ...)`,
which fires the `chpwd` hook in a subshell,
so `load-nvmrc` ran on each such completion, slowly in large directories.
`compstate` is set only inside completion widgets.
Checking `ZSH_SUBSHELL` instead would also skip deliberate subshells, like `( cd proj && npm test )`,
and checking it along with `WIDGET` would skip any widget's subshell, not just completion's.
Fixes #3606
This commit is contained in:
1 parent
ecf142d1f0
commit
a4fadf1eae
1 file changed
+2
@@ -862,6 +862,8 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e
|
||||
autoload -U add-zsh-hook
|
||||
|
||||
load-nvmrc() {
|
||||
# skip during tab completion, which can run `cd` in a subshell
|
||||
(( $+compstate )) && return
|
||||
local nvmrc_path
|
||||
nvmrc_path="$(nvm_find_nvmrc)"
|
||||
|
||||
|
||||
Reference in new issue
Block a user