Use native preview scroll of fzf 0.22.0

This allows you to scroll upwards

Fix #1053
Fix #751
Fix #749
This commit is contained in:
Junegunn Choi
2020-07-30 12:51:06 +09:00
parent 23dda8602f
commit 4145f53f3d
5 changed files with 14 additions and 24 deletions

View File

@@ -39,23 +39,9 @@ if [ -z "$CENTER" ]; then
CENTER=0
fi
if [ -n "$FZF_PREVIEW_LINES" ]; then
LINES=$FZF_PREVIEW_LINES
else
if [ -r /dev/tty ]; then
LINES=$(stty size < /dev/tty | awk '{print $1}')
else
LINES=40
fi
fi
FIRST=$(($CENTER-$LINES/3))
FIRST=$(($FIRST < 1 ? 1 : $FIRST))
LAST=$((${FIRST}+${LINES}-1))
if [ -z "$FZF_PREVIEW_COMMAND" ] && command -v bat > /dev/null; then
bat --style="${BAT_STYLE:-numbers}" --color=always --pager=never \
--line-range=$FIRST:$LAST --highlight-line=$CENTER "$FILE"
--highlight-line=$CENTER "$FILE"
exit $?
fi
@@ -63,7 +49,7 @@ DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}"
CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND}
CMD=${CMD//{\}/$(printf %q "$FILE")}
eval "$CMD" 2> /dev/null | awk "NR >= $FIRST && NR <= $LAST { \
eval "$CMD" 2> /dev/null | awk "{ \
if (NR == $CENTER) \
{ gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \
else printf(\"$RESET%s\n\", \$0); \