Skip to content

Commit

Permalink
Exit live history search after accepting a match
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Nov 29, 2021
1 parent ccf7d59 commit c130eee
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions functions/widget/.autocomplete.complete-word.completion-widget
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
#!/bin/zsh
zmodload -F zsh/terminfo p:terminfo
local -a match=() mbegin=() mend=() # `zstyle` for some reason assigns these.

local -P key_name=
case $KEYS in
( $'\t' ) key_name=tab ;;
( $terminfo[kcbt] ) key_name=shift-tab ;;
esac

local +h curcontext=${curcontext:-${WIDGET}:::}
local +h -a comppostfuncs=( .autocomplete.complete-word.post "$comppostfuncs[@]" )
() {
local -a match=() mbegin=() mend=() # `zstyle` for some reason assigns these.
local +h curcontext=${curcontext:-${WIDGET}:::}
local +h -a comppostfuncs=( .autocomplete.complete-word.post "$comppostfuncs[@]" )

if [[ -z $compstate[old_list] ]] || [[ $WIDGET == *menu-* && -v _autocomplete__partial_list ]] ||
( builtin zstyle -t ":autocomplete:${key_name}:" insert-unambiguous &&
[[ -n $_autocomplete__unambiguous ]] ); then
_main_complete
else
compstate[old_list]=keep
[[ $key_name == shift-tab && $_lastcomp[tags] == *all-matches ]] &&
compstate[insert]=all
_main_complete -
fi
[[ _lastcomp[nmatches] -gt 0 && -n $compstate[insert] ]]
if [[ -z $compstate[old_list] ]] || [[ $WIDGET == *menu-* && -v _autocomplete__partial_list ]] ||
( builtin zstyle -t ":autocomplete:${key_name}:" insert-unambiguous &&
[[ -n $_autocomplete__unambiguous ]] ); then
_main_complete
else
compstate[old_list]=keep
[[ $key_name == shift-tab && $_lastcomp[tags] == *all-matches ]] &&
compstate[insert]=all
_main_complete -
fi
}
[[ _lastcomp[nmatches] -gt 0 && -n $compstate[insert] ]] &&
unset curcontext

0 comments on commit c130eee

Please sign in to comment.