mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
Merge of users/11790: avoid nounset.
This commit is contained in:
parent
1d77e36c39
commit
4ecf5b41ea
2 changed files with 41 additions and 0 deletions
21
Functions/Zle/down-line-or-beginning-search
Normal file
21
Functions/Zle/down-line-or-beginning-search
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Like down-line-or-search, but uses the whole line prefix up to the
|
||||
# cursor position for searching forwards.
|
||||
|
||||
emulate -L zsh
|
||||
|
||||
if [[ ${+NUMERIC} -eq 0 &&
|
||||
( $LASTWIDGET = $__searching || $RBUFFER != *$'\n'* ) ]]
|
||||
then
|
||||
[[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
|
||||
__searching=$WIDGET
|
||||
__savecursor=$CURSOR
|
||||
if zle .history-beginning-search-forward; then
|
||||
[[ $RBUFFER = *$'\n'* ]] ||
|
||||
zstyle -T ':zle:down-line-or-beginning-search' leave-cursor &&
|
||||
zle .end-of-line
|
||||
return
|
||||
fi
|
||||
[[ $RBUFFER = *$'\n'* ]] || return
|
||||
fi
|
||||
__searching=''
|
||||
zle .down-line-or-history
|
20
Functions/Zle/up-line-or-beginning-search
Normal file
20
Functions/Zle/up-line-or-beginning-search
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Like up-line-or-search, but uses the whole line prefix up to the
|
||||
# cursor position for searching backwards.
|
||||
|
||||
emulate -L zsh
|
||||
|
||||
if [[ $LBUFFER == *$'\n'* ]]; then
|
||||
zle .up-line-or-history
|
||||
__searching=''
|
||||
elif [[ -n $PREBUFFER ]] &&
|
||||
zstyle -t ':zle:up-line-or-beginning-search' edit-buffer
|
||||
then
|
||||
zle .push-line-or-edit
|
||||
else
|
||||
[[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
|
||||
__savecursor=$CURSOR
|
||||
__searching=$WIDGET
|
||||
zle .history-beginning-search-backward
|
||||
zstyle -T ':zle:up-line-or-beginning-search' leave-cursor &&
|
||||
zle .end-of-line
|
||||
fi
|
Loading…
Reference in a new issue