mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-11-22 03:13:09 +00:00
Workaround for Zsh versions like 5.0.2 – Ctrl-V to cancel search
This commit is contained in:
parent
0623cd6d9c
commit
a91406590e
1 changed files with 17 additions and 2 deletions
|
@ -175,6 +175,12 @@ _hsmw_delete_char() {
|
||||||
_hsmw_simulate_widget
|
_hsmw_simulate_widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_hsmw_cancel_accept() {
|
||||||
|
BUFFER=""
|
||||||
|
__hsmw_hcw_index=-1
|
||||||
|
zle .accept-line
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$__hsmw_hcw_call_count" -eq "1" ]; then
|
if [ "$__hsmw_hcw_call_count" -eq "1" ]; then
|
||||||
# Make the hsmw keymap a copy of the current main
|
# Make the hsmw keymap a copy of the current main
|
||||||
bindkey -N hsmw emacs
|
bindkey -N hsmw emacs
|
||||||
|
@ -254,15 +260,24 @@ if [ "$__hsmw_hcw_call_count" -eq "1" ]; then
|
||||||
zle -N "$pdown_widget" _hsmw_simulate_widget
|
zle -N "$pdown_widget" _hsmw_simulate_widget
|
||||||
zle -N "$pup_widget" _hsmw_simulate_widget
|
zle -N "$pup_widget" _hsmw_simulate_widget
|
||||||
|
|
||||||
|
# Add Ctrl-V binding to cancel search
|
||||||
|
# A workaround for Zsh versions like 5.0.2
|
||||||
|
zle -N _hsmw_cancel_accept
|
||||||
|
bindkey -M hsmw "^V" _hsmw_cancel_accept
|
||||||
|
|
||||||
# Trap INT to manually interrupt Zle to work around a bug
|
# Trap INT to manually interrupt Zle to work around a bug
|
||||||
trap 'zle && zle .send-break' INT
|
trap 'zle && zle .send-break' INT
|
||||||
|
|
||||||
if zle .recursive-edit -K hsmw; then
|
if zle .recursive-edit -K hsmw; then
|
||||||
|
if [[ "$__hsmw_hcw_index" -gt "0" ]]; then
|
||||||
BUFFER="${__hsmw_hcw_found[__hsmw_hcw_index]}"
|
BUFFER="${__hsmw_hcw_found[__hsmw_hcw_index]}"
|
||||||
CURSOR="${#BUFFER}"
|
CURSOR="${#BUFFER}"
|
||||||
else
|
else
|
||||||
BUFFER=""
|
BUFFER=""
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
BUFFER=""
|
||||||
|
fi
|
||||||
POSTDISPLAY=""
|
POSTDISPLAY=""
|
||||||
|
|
||||||
# Restore self-insert, backward-delete-char, delete-char
|
# Restore self-insert, backward-delete-char, delete-char
|
||||||
|
|
Loading…
Reference in a new issue