tagpreview: open vim in readonly mode, and exit on failure (#1488)

- When computing the center line, 'exit' on failure instead of 'return'.
- Open vim in read-only mode to avoid a non-zero exit code if the file is
already opened.

Signed-off-by: Nicolas VINCENT <nico.vince@gmail.com>
This commit is contained in:
Nicolas
2023-07-17 11:57:01 +02:00
committed by GitHub
parent 1dcdb21db6
commit e0d131d953

View File

@@ -30,10 +30,10 @@ else
exit 1
fi
CENTER="$("${VIMNAME}" -i NONE -u NONE -e -m -s "${FILE}" \
CENTER="$("${VIMNAME}" -R -i NONE -u NONE -e -m -s "${FILE}" \
-c "set nomagic" \
-c "${EXCMD}" \
-c 'let l=line(".") | new | put =l | print | qa!')" || return
-c 'let l=line(".") | new | put =l | print | qa!')" || exit
START_LINE="$(( CENTER - FZF_PREVIEW_LINES / 2 ))"
if (( START_LINE <= 0 )); then