junegunn / fzf.vim

fzf :heart: vim
MIT License
9.62k stars 584 forks source link

tagpreview.sh - preview not centering with error #1477

Open noisyscanner opened 1 year ago

noisyscanner commented 1 year ago

When using :Tags, the preview window does not display the correct line number, but displays the below error.

image

Seems that the below snippet in tagpreview.sh is the cause:

CENTER="$("${VIMNAME}" -i NONE -u NONE -e -m -s "${FILE}" \
              -c "set nomagic" \
              -c "${EXCMD}" \
              -c 'let l=line(".") | new | put =l | print | qa!')" || return

A simple replace with the below works for me, but I am wondering the implications of this. Ie, just take the line number we already get passed in via EXCMD and use that for the center.

CENTER=$(echo "${EXCMD}" | awk -F ' ' '{print $1}')

I can stick a PR in for this if it looks fine

junegunn commented 1 year ago

While using return in that context is wrong (it should be something like exit 1), :Tags works fine on my machine with proper preview support.

image

Any idea why the command is not working for you in the first place?

noisyscanner commented 1 year ago

For me both with vim 9.0 and nvim 0.9.0, it just returns the number of the last line in the tags file Eg

export VIMNAME=nvim
export FILE=whatever-it-does-not-matter
export EXCMD="47 tags"

nvim -i NONE -u NONE -e -m -s "${FILE}" \
  -c "set nomagic" \
  -c "${EXCMD}" \
  -c 'let l=line(".") | new | put =l | print | qa!'

# returns 8216, the number of lines in the `tags` file

Not sure I fully understand what this command is doing. EXCMD contains the line number in $FILE (ie 47 above), is it not ok to simply use that?