mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 00:51:05 +02:00
zsh-workers/8428
This commit is contained in:
parent
e0b26186f1
commit
270b48432d
1 changed files with 15 additions and 3 deletions
|
@ -25,14 +25,12 @@
|
||||||
# error message.
|
# error message.
|
||||||
|
|
||||||
predict-on() {
|
predict-on() {
|
||||||
setopt localoptions unset noksharrays
|
|
||||||
zle -N self-insert insert-and-predict
|
zle -N self-insert insert-and-predict
|
||||||
zle -N magic-space insert-and-predict
|
zle -N magic-space insert-and-predict
|
||||||
zle -N backward-delete-char delete-backward-and-predict
|
zle -N backward-delete-char delete-backward-and-predict
|
||||||
zle -N delete-char-or-list delete-no-predict
|
zle -N delete-char-or-list delete-no-predict
|
||||||
}
|
}
|
||||||
predict-off() {
|
predict-off() {
|
||||||
setopt localoptions unset noksharrays
|
|
||||||
zle -A .self-insert self-insert
|
zle -A .self-insert self-insert
|
||||||
zle -A .magic-space magic-space
|
zle -A .magic-space magic-space
|
||||||
zle -A .backward-delete-char backward-delete-char
|
zle -A .backward-delete-char backward-delete-char
|
||||||
|
@ -53,6 +51,8 @@ insert-and-predict () {
|
||||||
if [[ ${KEYS[-1]} != ' ' ]]
|
if [[ ${KEYS[-1]} != ' ' ]]
|
||||||
then
|
then
|
||||||
integer curs=$CURSOR
|
integer curs=$CURSOR
|
||||||
|
local -a +h comppostfuncs
|
||||||
|
comppostfuncs=( predict-limit-list )
|
||||||
zle complete-word
|
zle complete-word
|
||||||
CURSOR=$curs
|
CURSOR=$curs
|
||||||
fi
|
fi
|
||||||
|
@ -79,8 +79,20 @@ delete-backward-and-predict() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
delete-no-predict() {
|
delete-no-predict() {
|
||||||
predict-off
|
[[ $WIDGET != delete-char-or-list || -n $RBUFFER ]] && predict-off
|
||||||
zle .$WIDGET "$@"
|
zle .$WIDGET "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This is a helper function for autocompletion to prevent long lists
|
||||||
|
# of matches from forcing a "do you wish to see all ...?" prompt.
|
||||||
|
|
||||||
|
predict-limit-list() {
|
||||||
|
if [[ compstate[list_lines]+BUFFERLINES -gt LINES ]]; then
|
||||||
|
compstate[list]=''
|
||||||
|
compstate[force_list]=yes
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle zsh autoloading conventions
|
||||||
|
|
||||||
[[ -o kshautoload ]] || predict-on "$@"
|
[[ -o kshautoload ]] || predict-on "$@"
|
||||||
|
|
Loading…
Reference in a new issue