mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-24 07:38:36 +00:00
[zsh] Keep current $BUFFER on ALT-C
Ideally, we could only use `print -sr` to update the command history. However, the "cd" command by ALT-C is added to the history only after we finalize the current command by pressing an additional enter key. i.e. The cd command from ALT-C is not visible when you hit Up arrow. But it appears once you hit enter key. So when the current buffer is empty, we use `zle accept-line` so that the command history is immediately updated. Close #2200
This commit is contained in:
parent
82c4af2902
commit
9dfca77c36
@ -87,10 +87,15 @@ fzf-cd-widget() {
|
|||||||
zle redisplay
|
zle redisplay
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
BUFFER="cd ${(q)dir}"
|
if [ -z "$BUFFER" ]; then
|
||||||
unset dir # ensure this doesn't end up appearing in prompt expansion
|
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
|
||||||
zle fzf-redraw-prompt
|
zle fzf-redraw-prompt
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user