Vimtex: Problem with files in symbolically linked directories when using Zathura

Created on 11 Sep 2020  Â·  11Comments  Â·  Source: lervag/vimtex

Issue
When vim opens a tex file located in a symbolically linked directory, and the pdf is opened in Zathura in a second monitor of the machine, mouse is moved back to the vim window every time after a backward search on the pdf.

minimal.vim

vim call plug#begin('~/.vim/plugged') Plug 'lervag/vimtex' call plug#end() let g:tex_flavor='latex' let g:vimtex_view_method='zathura'

minimal tex (a.tex)

```tex
\documentclass{article}

\begin{document}

This is line one.

This is line two.

\end{document}
```

Commands/Input
Set up the directories and files:

mkdir mydir
touch mydir/a.tex
ln -s mydir lndir
cd lndir
vim a.tex

Then compile the tex file (\ll).

Two zathura windows popped up, one for the pdf in the original directory (with correct forward search highlightings) and another for the pdf in the symbolically linked directory (without any highlightings or backward search function). (This is the bug discussed though unresolved in #1676 but not the focus here.) Close the zathura window for the pdf inside the symbolically linked directory.

Now move Zathura to the second monitor of the machine.
Do a backward search (Ctrl-LeftClick) on a line of the pdf.

Observed Behaviour
The mouse is moved to the center of the vim window.
This disrupts the workflow, since I now need to move my mouse back across the monitors if I want to backward search another line in the pdf or select the vim window.

Expected Behaviour
The mouse should be left at where I click on the pdf.
This is the behavior when working inside the original directory
(i.e. cd mydir; vim a.tex; \ll; Ctrl-LeftClick on pdf)

Output from VimtexInfo

System info
  OS: Linux 5.8.6-arch1-1
  Vim version: VIM 8.2 (1-1584)
  Has clientserver: true
  Servername: VIM1

vimtex project: a
  base: a.tex
  root: /home/david/vimtexbug/mydir
  tex: /home/david/vimtexbug/mydir/a.tex
  out: /home/david/vimtexbug/mydir/a.pdf
  log: /home/david/vimtexbug/mydir/a.log
  aux: /home/david/vimtexbug/mydir/a.aux
  fls: /home/david/vimtexbug/mydir/a.fls
  main parser: current file verified
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
    job: process 159984 run
    pid: 159984
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$new_viewer_always = "0
  viewer: Zathura
    xwin id: 33554435
    process: 
      pid: -
      cmd: zathura -x "/usr/bin/vim --servername VIM1 --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward
  qf: LaTeX logfile
    root: /home/david/vimtexbug/mydir
    addqflist: 58
    errorformat_saved: 
    fix_paths: 59
    main: /home/david/vimtexbug/mydir/a.tex
    set_errorformat: 57
  document class: article

Zathura config file (.config/zathura/zathurarc)
Empty

bug

All 11 comments

I hope it is OK that we look into this when the other issue is resolved. I don't use two screens, which make it challenging to address this. I have a small hope that properly solving #1676 may help also for this issue.

I'm curious, does Zathura now work as expected for you in general (except for this particular issue with two screens)? That is, #1676 is closed as resolved. There's a new related issue #1806, but it seems slightly different and I expect it might be something else.

Zathura works all fine for me when not being called by vim. For the current issue, I noticed that the Zathura window opened by vimtex often appears "disconnected" in the middle of my writing, that is, not being to do forward/backword search, as if it is an independent window on it's own. This happens pretty frequently, and I need to close the old zathura window, recompile, pop up a new window by calling for forward search.

pop up a new window by calling for forward search.

What do you mean by this? Do you mean that you open the window with \lv? Or that \lv works for doing forward search as long as the window was first opened after a \ll?

I would really want to figure these things out and make it work as expected in all cases, but it is hard when I'm not able to reproduce the problems. :\

What do you mean by this? Do you mean that you open the window with \lv?

Yes, that's what I did.

Or to put the symptoms in this way. Suppose I am in the middle of editing a tex file (i.e. ignoring all the behaviors at the beginning when the tex file was first opened in vim and compilation was done for the first time).

  1. Close all the other windows and make sure only vim is open.
  2. Do some editing on the tex file.
  3. Save. Compilation is auto triggered.
  4. Press \lv. A zathura window of the pdf pops up, with the current line in view and highlighted.
  5. Do more editings.
  6. Save. The pdf in the zathura window is auto updated.
  7. Press \lv. Zathura jumps to the current line, with highlightings.
  8. Keep editing and saving the tex file for a while. The same zathura window works fine as in the previous three steps.
  9. Starting at some point, this zathura window stops corresponding with vim.
  10. Do some editing on the tex file.
  11. Save. Vim says compilation completes, but the pdf in the zathura window is unchanged.
  12. Press \lv. A new zathura window pops up, with the current line in view and highlighted. The old zathura window is unchanged.
  13. Close the old zathura window.
  14. The last six steps will be repeated over and over again.

These symptoms are different from my initial description of the issue, which has more to do with backward search. Don't know if a separate issue should be created for this, but just put my observations here for your information. My hunch is that the bug is related to zathura and xdotools.

Or to put the symptoms in this way. Suppose I am in the middle of editing a tex file (i.e. ignoring all the behaviors at the beginning when the tex file was first opened in vim and compilation was done for the first time). ...

I think your steps clearly shows that things are initially working. The main question seems to be: Why does it _stop_ working. Again, since I can't reproduce this, I really can't debug it either. But I can help you debug it, if you are able to reproduce this on your end?

What I would do is something along the lines of the following:

...

8. Keep editing and saving the tex file for a while. The same zathura window works fine as in the previous three steps.

9. Starting at some point, this zathura window stops corresponding with vim.

At this point, I would begin to inspect the :VimtexInfo output, especially the viewer part. It should show the xwin id. Then, from a terminal, I would run xprop and/or xwininfo to inspect the X properties of the Zathora window, and in particular the Xwin ID; xprop | grep _NET_WM_SYNC_REQUEST_COUNTER. Or, with xdotool: xdotool search --class Zathura. The IDs need to match in order for things to work.

These symptoms are different from my initial description of the issue, which has more to do with backward search. Don't know if a separate issue should be created for this, but just put my observations here for your information. My hunch is that the bug is related to zathura and xdotools.

Let's keep things in one issue for now. There's been a small rush of Zathura related issues lately, but I've not been able to reproduce any of them except the one about symlinked directories (which I think is fixed now). It is crucial for me to reproduce the issues if I am to be able to fix them.

Thanks for the debugging tips. I will keep them in mind when I encounter the bug.

One question: Is it possible to reproduce this issue on a single-monitor setup? I don't use multiple monitors, so it is hard to reproduce your original issue description. :\

I remember the bug would eventually appear even on a single-monitor set up, if I work on the tex file for long enough. I haven't been using vimtex recently, so it's hard to narrow down the potential triggers of the bug.

I just tried vimtex again, with the latest version. Now \lv can still pop up a zathura window, but the current line is neither highlighted nor moved to the center of the screen. This is done on one monitor.

And still, everything works well on my end and I am not able to reproduce
your problem. :/

ons. 7. okt. 2020, 23:18 skrev Daiwei (David) Zhang <
[email protected]>:

I just tried vimtex again, with the latest version. Now \lv can still pop
up a zathura window, but the current line is neither highlighted nor moved
to the center of the screen. This is done on one monitor.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/lervag/vimtex/issues/1793#issuecomment-705199169, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHT34UOQUWCGVVZO3BZGILSJTLK5ANCNFSM4RGBCLJA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carloabelli picture carloabelli  Â·  3Comments

vanabel picture vanabel  Â·  6Comments

benutzer193 picture benutzer193  Â·  4Comments

LuxGiammi picture LuxGiammi  Â·  3Comments

sharethewisdom picture sharethewisdom  Â·  3Comments