-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exit live history search after accepting a match
- Loading branch information
1 parent
ccf7d59
commit c130eee
Showing
1 changed file
with
17 additions
and
14 deletions.
There are no files selected for viewing
31 changes: 17 additions & 14 deletions
31
functions/widget/.autocomplete.complete-word.completion-widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |