Show no preview when the address does not reach Vim

Ex mode starts on the last line, so an empty $FZFVIM_EXCMD centered the preview
at the end of the file and said nothing. Quit with an error instead, which the
existing '|| exit' turns into a blank preview.
This commit is contained in:
Junegunn Choi
2026-09-28 01:29:03 +09:00
parent 777e783382
commit 5ad2fa7bed
+7
View File
@@ -38,8 +38,15 @@ fi
export FZFVIM_EXCMD="${EXCMD}"
# WSL shares only the variables named in WSLENV with a Windows vim.exe
export WSLENV="FZFVIM_EXCMD/w${WSLENV:+:${WSLENV}}"
# Ex mode starts on the last line, so an address that did not reach Vim would
# center the preview there rather than say anything. Show nothing instead
REQUIRE_EXCMD=""
if [ -n "${EXCMD}" ]; then
REQUIRE_EXCMD='if empty($FZFVIM_EXCMD) | cquit | endif'
fi
CENTER="$("${VIMNAME}" -R -i NONE -u NONE -e -m -s "${FILE}" \
-c "set nomagic" \
-c "${REQUIRE_EXCMD}" \
-c 'silent sandbox execute $FZFVIM_EXCMD' \
-c 'let l=line(".") | new | put =l | print | qa!')" || exit