Commit Graph
12 Commits
Author SHA1 Message Date
Junegunn Choi 0097439b74 Show no preview for an entry with no address
Ex mode starts on the last line, so the preview reported the end of the file as
the tag, while every other path refuses such an entry.
2026-09-28 07:07:45 +09:00
Junegunn Choi b1c03ea0ef Drop an unreachable newline guard
'read' without '-d' stops at the first newline, so EXCMD never holds one, and a
newline inside the ':execute' string stays in the sandbox anyway.
2026-09-28 02:40:06 +09:00
Junegunn Choi 8039b2747c 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.
2026-09-28 01:57:21 +09:00
Junegunn Choi 5ad2fa7bed 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.
2026-09-28 01:29:03 +09:00
Junegunn Choi 777e783382 Name the preview variable in WSLENV
WSL shares only the variables listed there with a Windows vim.exe, as
s:preview_cmd already does for MSWINHOME. Untested, no WSL here.
2026-09-28 00:49:38 +09:00
Junegunn Choi 81ae642d5b Keep the whole tag address inside the preview sandbox
':sandbox' is a modifier and covers only the command up to the first '|', so an
address like '/pat/|!touch file' still ran the shell command as soon as an entry
was highlighted. ':execute' on a value taken from the environment keeps all of
it inside the sandbox, and takes the address out of the '-c' string as well.

:Helptags previews a plugin's doc/tags through the same script.
2026-09-28 00:08:49 +09:00
Junegunn Choi 9705771895 Run the tag address in a sandbox in the preview too
A preview runs as soon as an entry is highlighted, so a crafted tags file did
not even need to be selected to get a shell command out of
'vim -c "silent {excmd}"'.

The preview Vim starts with '-u NONE' and exits right after, so the sandbox
alone is enough there; nothing it still permits outlives the process.
2026-09-27 23:20:27 +09:00
Junegunn Choi 6f28c8c7bb [Tags] Fix preview on Vim 9.1
Fix #1555
2024-08-01 15:20:41 +09:00
Nicolas e0d131d953 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>
2023-07-17 18:57:01 +09:00
Greg Fisher 1ef72b14cc Use nvim if vim not installed (#1262)
The `tagpreview.sh` script is hardcoded to the `vim` binary. For users that only
have  Neovim installed an error is displayed and no preview is rendered.

This change addresses this by falling back to the `nvim` binary if the `vim`
binary isn't present.
2021-03-14 12:08:29 +09:00
Ingo Meyer 36de5db9f0 [Tagpreview] Handle absolute file paths correctly (#1229)
Fix #1228
2021-01-20 20:34:56 +09:00
1fcdee55cc [Tags] Add a tag preview with a custom tagpreview.sh script (#1223)
* Add a tag preview with a custom `tagpreview.sh` script

* [Tags] Respect g:fzf_preview_window

Co-authored-by: Ingo Meyer <IJ_M@gmx.de>
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2021-01-17 22:36:02 +09:00