Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tagpreview.sh - preview not centering with error #1477

Open
5 tasks done
noisyscanner opened this issue May 16, 2023 · 2 comments
Open
5 tasks done

tagpreview.sh - preview not centering with error #1477

noisyscanner opened this issue May 16, 2023 · 2 comments

Comments

@noisyscanner
Copy link

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
Copy link
Owner

junegunn commented Jun 5, 2023

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
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants