James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.66k stars 530 forks source link

Unable to sync pdf if tab is opened in current editor group #4336

Closed rnatella closed 2 months ago

rnatella commented 2 months ago

Please fill the following fields with a star (*) and provide as much related information as possible.

Pre-checks*

Please change the following [ ] to [x] for confirmation.

  • [x] The issue has not been reported in this repository.
  • [x] The issue remains after disabling all other extensions and restarting Visual Studio Code.
  • [x] The FAQ cannot address the issue.
  • [x] The issue is not related to compiling a document, or the document can be successfully compiled in the OS terminal but not in Visual Studio Code with this extension.

Environment*

Please write exact version numbers instead of descriptors such as latest.

  • Operating System: MacOS X 14.5
  • Visual Studio Code Version: 1.92.1
  • LaTeX Workshop Version: 10.1.0
  • TeX Distribution Version: TeX Live 2024

Please list the environment and version number if you are using VSCodium, Snap or Flatpack versions of Visual Studio Code, and/or Visual Studio Code Remote Containers/SSH/WSL.

  • not applicable

The Issue*

When compiling the project, I would like to automatically focus the PDF viewer. It works well when the tab viewer is configured to open in a new editor group (the default configuration). However, it does not work (i.e., no sync) when the tab viewer is configured to open in the current editor group.

Reproduction Steps

Please list out the steps to reproduce your bug. Include relevant environmental variables or any other configuration.

  1. Enable forward synctex at cursor position after compiling project
  2. Set "Tab: Editor Group" to "current"
  3. Compile project. The project will be built and the new tab opened in the current editor group. However, the PDF will be stuck at the first page of the document.

Expected Behavior

What were you expecting to see? Include any relevant examples or documentation links. The PDF should be focused at cursor position, as it happens if the "Tab: Editor Group" is not set to "current

Logs

LaTeX Workshop Output*

Please paste the whole log messages below, not parts of ones. The log should start with New log placeholder %WS1% registered.

[17:18:59.855][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:61930/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRlVzZXJzJTJGcm5hdGVsbGElMkZnaXQlMkZzb2Z0d2FyZS1zZWN1cml0eS1ib29rJTJGYm9vay5wZGY .
[17:18:59.855][Cacher][Watcher] Watched %WS1%/book.pdf by the .pdf watcher.
[17:18:59.855][Event] FILE_WATCHED: "%WS1%/book.pdf"
[17:18:59.875][Viewer] Open PDF tab for file://%WS1%/book.pdf
[17:19:00.009][Viewer] Handle data type: open
[17:19:00.042][Server] Preview PDF file: file://%WS1%/book.pdf
[17:19:00.119][Viewer] Handle data type: loaded
[17:19:00.119][Event] VIEWER_PAGE_LOADED
[17:19:00.119][Viewer] SyncTex after build invoked.
[17:19:00.119][Locator] No active editor found.

Developer Tools Console

Please paste the whole log messages below, not parts of ones. This console logs can sometimes be very important in many cases. To access the log, click Help -> Toggle Developer Tools -> Console.

I am unable to find it :-(

Anything Else?

Add any other context about the problem below.

James-Yu commented 2 months ago

This is a limit by vscode, unfortunately. Only when the viewer is loaded, the extension may start synctex-ing. However, when doing so, the extension needs to retrieve the cursor location in the file, which is invisible and cannot be obtained from any vscode API.

tldr: both viewer and text editor have to be visible to make it function correctly.

James-Yu commented 2 months ago

There might be a patch on a related issue, may or may not resolve this problem.

rnatella commented 2 months ago

Thank you, I can test it once it is updated, in the meanwhile I will use the separate editor group.

About the separate editor group: when I open the PDF preview, the focus stays in the Latex file editor. Is there any option to change the focus to the PDF preview tab? That would allow me to quickly close the PDF preview tab using the keyboard.

James-Yu commented 2 months ago

afaik no as it’s a vscode limit. I will keep an eye on it though.

rnatella commented 2 months ago

Ok, thanks!