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 address goes to ':execute' as a string literal with its quotes doubled, since
':sandbox' as a modifier would stop at the first '|'.
An entry with no address is refused rather than previewing the last line of the
file, which is where Ex mode leaves the cursor.
- 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>
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.