mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-10-11 07:39:15 +08:00
Hand the preview address to Vim as an argument again
Through the environment it depended on WSLENV reaching a Windows vim.exe, and the guard for that turned a missing address into a blank preview. An argument always arrives. Doubling the quotes keeps it one ':execute' string, so the sandbox still covers all of it.
This commit is contained in:
1 file changed
+7
-14
+7
-14
@@ -32,22 +32,15 @@ fi
|
|||||||
|
|
||||||
# The address comes from a tags file, which can be untrusted, and a preview runs
|
# The address comes from a tags file, which can be untrusted, and a preview runs
|
||||||
# as soon as an entry is highlighted. Sandboxed as a builtin tag jump is, so that
|
# as soon as an entry is highlighted. Sandboxed as a builtin tag jump is, so that
|
||||||
# it cannot run a shell command or touch a file. ':sandbox' on its own only
|
# it cannot run a shell command or touch a file. ':sandbox' on its own only covers
|
||||||
# covers the command up to the first '|', hence 'sandbox execute' on a value
|
# the command up to the first '|', so hand the whole address to ':execute' as a
|
||||||
# passed through the environment, which keeps the whole address inside
|
# string literal, doubling the quotes in it. A newline would end that line and
|
||||||
export FZFVIM_EXCMD="${EXCMD}"
|
# leave the rest outside the sandbox, and no tags file holds one, so drop them
|
||||||
# WSL shares only the variables named in WSLENV with a Windows vim.exe
|
EXCMD=${EXCMD//$'\n'/ }
|
||||||
export WSLENV="FZFVIM_EXCMD/w${WSLENV:+:${WSLENV}}"
|
EXCMD_LITERAL=${EXCMD//\'/\'\'}
|
||||||
# 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}" \
|
CENTER="$("${VIMNAME}" -R -i NONE -u NONE -e -m -s "${FILE}" \
|
||||||
-c "set nomagic" \
|
-c "set nomagic" \
|
||||||
-c "${REQUIRE_EXCMD}" \
|
-c "silent sandbox execute '${EXCMD_LITERAL}'" \
|
||||||
-c 'silent sandbox execute $FZFVIM_EXCMD' \
|
|
||||||
-c 'let l=line(".") | new | put =l | print | qa!')" || exit
|
-c 'let l=line(".") | new | put =l | print | qa!')" || exit
|
||||||
|
|
||||||
START_LINE="$(( CENTER - FZF_PREVIEW_LINES / 2 ))"
|
START_LINE="$(( CENTER - FZF_PREVIEW_LINES / 2 ))"
|
||||||
|
|||||||
Reference in new issue
Block a user