mirror of
https://github.com/junegunn/fzf
synced 2024-11-18 09:28:40 +00:00
[zsh] Don't run precmd hooks in cd widget (#2340)
`precmd` hooks expect the Zsh Line Editor to not be active. Running these when the ZLE is active can lead to unpredictable results. See https://github.com/marlonrichert/zsh-autocomplete/issues/180
This commit is contained in:
parent
fcd896508b
commit
43b3b907f8
@ -68,16 +68,6 @@ fzf-file-widget() {
|
|||||||
zle -N fzf-file-widget
|
zle -N fzf-file-widget
|
||||||
bindkey '^T' fzf-file-widget
|
bindkey '^T' fzf-file-widget
|
||||||
|
|
||||||
# Ensure precmds are run after cd
|
|
||||||
fzf-redraw-prompt() {
|
|
||||||
local precmd
|
|
||||||
for precmd in $precmd_functions; do
|
|
||||||
$precmd
|
|
||||||
done
|
|
||||||
zle reset-prompt
|
|
||||||
}
|
|
||||||
zle -N fzf-redraw-prompt
|
|
||||||
|
|
||||||
# ALT-C - cd into the selected directory
|
# ALT-C - cd into the selected directory
|
||||||
fzf-cd-widget() {
|
fzf-cd-widget() {
|
||||||
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
||||||
@ -88,16 +78,12 @@ fzf-cd-widget() {
|
|||||||
zle redisplay
|
zle redisplay
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ -z "$BUFFER" ]; then
|
zle push-line # Clear buffer. Auto-restored on next prompt.
|
||||||
BUFFER="cd ${(q)dir}"
|
BUFFER="cd ${(q)dir}"
|
||||||
zle accept-line
|
zle accept-line
|
||||||
else
|
|
||||||
print -sr "cd ${(q)dir}"
|
|
||||||
cd "$dir"
|
|
||||||
fi
|
|
||||||
local ret=$?
|
local ret=$?
|
||||||
unset dir # ensure this doesn't end up appearing in prompt expansion
|
unset dir # ensure this doesn't end up appearing in prompt expansion
|
||||||
zle fzf-redraw-prompt
|
zle reset-prompt
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
zle -N fzf-cd-widget
|
zle -N fzf-cd-widget
|
||||||
|
Loading…
Reference in New Issue
Block a user