about summary refs log tree commit diff
path: root/Functions/Zle/down-line-or-beginning-search
blob: 4c713f197774a3f3719341475dee081e31a74c75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Like down-line-or-search, but uses the whole line prefix up to the
# cursor position for searching forwards.

emulate -L zsh

typeset -g __searching __savecursor

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