texlab icon indicating copy to clipboard operation
texlab copied to clipboard

With the zed latex extension, Previewer opens often in the wrong position

Open mocenigo opened this issue 4 months ago • 3 comments

Actual cursor position and position in fwd_search.rs / ForwardSearch differ.

I am using Zed Zed 0.154.3 and the texlab 5.19.0 with zed-latex 0.0.7. My PDF previewer is Skim.

I often observe that upon saving, the Previewer does not open in the position where the cursor was in the tex file at the moment I actually saved. It is usually a previous position, and only after I edit a bit the posizion is adjourned. To reproduce, I also do not move the cursor after hitting cmd-S until the Previewer comes to the foreground.

I thus re-compiled texlab with debugging log force-activated and a separated log file, in fwd_search.rs I added outputs for child, child.cursor and line (such as log::debug!("[FwdSearch] child={:?}", &child);) and I can read the following in the log output:

DEBUG - [FwdSearch] child=Document("file:///Users/mocenigo/Research/PAC-Analysis/paper_short/truncated-reduced.tex") DEBUG - [FwdSearch] child.cursor=LineCol { line: 0, col: 0 } DEBUG - [FwdSearch] line="1"

whereas I know I have moevd to line 955 and the position given in the same log a few lines before is

DEBUG - < {"jsonrpc":"2.0","id":3,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///Users/mocenigo/Research/PAC-Analysis/paper_short/truncated-reduced.tex"},"position":{"line":955,"character":16}}}

Even if a movement of the cursor is finally detected, the two places are often out of sync and the Previewer opens in the wrong place.

I do not know whether the bug is in texlab or caused by a bug in Zed.

mocenigo avatar Sep 30 '24 13:09 mocenigo