James-Yu / LaTeX-Workshop

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

Synctex doesn't work properly when more than one pdf is displayed #4304

Closed xuezes closed 2 weeks ago

xuezes commented 2 weeks 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: Windows 11
  • Visual Studio Code Version: 1.90.2
  • LaTeX Workshop Version: 10.1.0
  • TeX Distribution Version: TeX Live 2024

The Issue*

Please briefly describe the issue you come across.

  • When the pdf corresponding to the tex file is open in the right tab, but not the one displaying, calling synctex would open that pdf again in the left instead of making the right one active

https://github.com/James-Yu/LaTeX-Workshop/assets/55419707/a00130f5-5720-42a7-930d-102b06e6094d

Reproduction Steps

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

  1. Open tst1.tex and synctex from cursor (tst1.pdf becomes active on the right, and location of the cursor is highlighted)
  2. Open tst2.tex and synctex from cursor (tst2.pdf becomes active on the right, and location of the cursor is highlighted)
  3. Go to tst1.tex and synctex from cursor, it opens a new tst1.pdf on the left.

Expected Behavior

What were you expecting to see? Include any relevant examples or documentation links.

  • tst1.pdf on the right should become active, and the location of the cursor is synched.

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:05:32.071][Event] STRUCTURE_UPDATED
[17:05:39.483][Commander] SYNCTEX command invoked.
[17:05:39.484][Locator] Forward from d:\Downloads\New folder (6)\tst1.tex to d:\Downloads\New folder (6)\.latextmp\tst1.pdf on line 6.
[17:05:39.509][Viewer] PDF is not opened: d:\Downloads\New folder (6)\.latextmp\tst1.pdf , try opening.
[17:05:39.581][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:7435/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmQlM0ElMkZEb3dubG9hZHMlMkZOZXclMjBmb2xkZXIlMjAoNiklMkYubGF0ZXh0bXAlMkZ0c3QxLnBkZg .
[17:05:39.582][Cacher][Watcher] Watched d:\Downloads\New folder (6)\.latextmp\tst1.pdf by the .pdf watcher.
[17:05:39.582][Event] FILE_WATCHED: "d:\\Downloads\\New folder (6)\\.latextmp\\tst1.pdf"
[17:05:39.626][Viewer] Open PDF tab for file:///d:/Downloads/New folder (6)/.latextmp/tst1.pdf
[17:05:39.627][Viewer] PDF cannot be opened: d:\Downloads\New folder (6)\.latextmp\tst1.pdf .
[17:05:39.798][Viewer] Handle data type: open
[17:05:39.869][Server] Preview PDF file: file:///d:/Downloads/New folder (6)/.latextmp/tst1.pdf
[17:05:39.935][Viewer] Handle data type: loaded
[17:05:39.935][Event] VIEWER_PAGE_LOADED
[17:05:39.935][Viewer] SyncTex after build invoked.
[17:05:39.935][Locator] Forward from d:\Downloads\New folder (6)\tst1.tex to d:\Downloads\New folder (6)\.latextmp\tst1.pdf on line 6.
[17:05:39.960][Viewer] Try to synctex d:\Downloads\New folder (6)\.latextmp\tst1.pdf
[17:05:40.763][Root] Current workspace folders: undefined
[17:05:40.765][Root] Found root file from active editor: d:\Downloads\New folder (6)\tst2.tex
[17:05:40.765][Root] Root file changed: from d:\Downloads\New folder (6)\tst2.tex to d:\Downloads\New folder (6)\tst2.tex, langID latex . Refresh dependencies
[17:05:40.765][Event] ROOT_FILE_CHANGED: "d:\\Downloads\\New folder (6)\\tst2.tex"
[17:05:40.765][Cacher][Watcher] Reset.
[17:05:40.766][Cacher][Watcher] Reset.
[17:05:40.766][Cacher] Adding d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.766][Cacher][Watcher] Watched d:\Downloads\New folder (6)\tst2.tex with a new .* watcher on d:\Downloads\New folder (6) .
[17:05:40.767][Event] FILE_WATCHED: "d:\\Downloads\\New folder (6)\\tst2.tex"
[17:05:40.767][Cacher] Caching d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.767][Event] ROOT_FILE_SEARCHED
[17:05:40.768][Linter] ChkTeX lints root d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.768][Linter][ChkTeX] Linter for ChkTeX command The command is F:\texlive\2024\bin\windows\chktex.exe:["-n22","-n30","-e16","-q","-n1","-n12","-n45","-n44","-n46","-n21","-n24","-n6","-n3","-f%f:%l:%c:%d:%k:%n:%m\n","d:\\Downloads\\New folder (6)\\tst2.tex"].
[17:05:40.772][Event] STRUCTURE_UPDATED
[17:05:40.827][Cacher] Updated inputs of d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.827][Cacher] Parse LaTeX AST: d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.832][Cacher] Parsed LaTeX AST in 4.66 ms: d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.833][File] kpsewhich cache hit on article.cls: f:/texlive/2024/texmf-dist/tex/latex/base/article.cls .
[17:05:40.834][Cacher] Updated elements in 0.90 ms: d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.834][Event] FILE_PARSED: "d:\\Downloads\\New folder (6)\\tst2.tex"
[17:05:40.835][Structure] Structure force updated with 0 root sections for d:\Downloads\New folder (6)\tst2.tex .
[17:05:40.835][Event] STRUCTURE_UPDATED
[17:05:40.865][Cacher] Parsing .fls d:\Downloads\New folder (6)\.latextmp\tst2.fls .
[17:05:40.905][Cacher] Found .aux d:\Downloads\New folder (6)\.latextmp\tst2.aux from .fls d:\Downloads\New folder (6)\.latextmp\tst2.fls , parsing.
[17:05:40.907][Cacher] Parsed .aux d:\Downloads\New folder (6)\.latextmp\tst2.aux .
[17:05:40.907][Cacher] Parsed .fls d:\Downloads\New folder (6)\.latextmp\tst2.fls .
[17:05:41.431][Linter] Linter for root successfully finished in 0s 660ms
[17:05:41.432][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[17:05:41.432][Linter][ChkTeX] Logged 0 messages.
[17:05:42.073][Commander] SYNCTEX command invoked.
[17:05:42.073][Locator] Forward from d:\Downloads\New folder (6)\tst2.tex to d:\Downloads\New folder (6)\.latextmp\tst2.pdf on line 16.
[17:05:42.101][Viewer] PDF is not opened: d:\Downloads\New folder (6)\.latextmp\tst2.pdf , try opening.
[17:05:42.128][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:7435/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmQlM0ElMkZEb3dubG9hZHMlMkZOZXclMjBmb2xkZXIlMjAoNiklMkYubGF0ZXh0bXAlMkZ0c3QyLnBkZg .
[17:05:42.129][Cacher][Watcher] Watched d:\Downloads\New folder (6)\.latextmp\tst2.pdf by the .pdf watcher.
[17:05:42.129][Event] FILE_WATCHED: "d:\\Downloads\\New folder (6)\\.latextmp\\tst2.pdf"
[17:05:42.149][Viewer] Open PDF tab for file:///d:/Downloads/New folder (6)/.latextmp/tst2.pdf
[17:05:42.149][Viewer] PDF cannot be opened: d:\Downloads\New folder (6)\.latextmp\tst2.pdf .
[17:05:42.249][Viewer] Handle data type: open
[17:05:42.306][Server] Preview PDF file: file:///d:/Downloads/New folder (6)/.latextmp/tst2.pdf
[17:05:42.364][Viewer] Handle data type: loaded
[17:05:42.365][Event] VIEWER_PAGE_LOADED
[17:05:42.365][Viewer] SyncTex after build invoked.
[17:05:42.365][Locator] Forward from d:\Downloads\New folder (6)\tst2.tex to d:\Downloads\New folder (6)\.latextmp\tst2.pdf on line 16.
[17:05:42.389][Viewer] Try to synctex d:\Downloads\New folder (6)\.latextmp\tst2.pdf
[17:05:43.406][Root] Current workspace folders: undefined
[17:05:43.408][Root] Found root file from active editor: d:\Downloads\New folder (6)\tst1.tex
[17:05:43.408][Root] Root file changed: from d:\Downloads\New folder (6)\tst1.tex to d:\Downloads\New folder (6)\tst1.tex, langID latex . Refresh dependencies
[17:05:43.408][Event] ROOT_FILE_CHANGED: "d:\\Downloads\\New folder (6)\\tst1.tex"
[17:05:43.409][Cacher][Watcher] Reset.
[17:05:43.409][Cacher][Watcher] Reset.
[17:05:43.409][Cacher] Adding d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.410][Cacher][Watcher] Watched d:\Downloads\New folder (6)\tst1.tex with a new .* watcher on d:\Downloads\New folder (6) .
[17:05:43.410][Event] FILE_WATCHED: "d:\\Downloads\\New folder (6)\\tst1.tex"
[17:05:43.410][Cacher] Caching d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.411][Event] ROOT_FILE_SEARCHED
[17:05:43.411][Linter] ChkTeX lints root d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.412][Linter][ChkTeX] Linter for ChkTeX command The command is F:\texlive\2024\bin\windows\chktex.exe:["-n22","-n30","-e16","-q","-n1","-n12","-n45","-n44","-n46","-n21","-n24","-n6","-n3","-f%f:%l:%c:%d:%k:%n:%m\n","d:\\Downloads\\New folder (6)\\tst1.tex"].
[17:05:43.415][Event] STRUCTURE_UPDATED
[17:05:43.466][Cacher] Updated inputs of d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.467][Cacher] Parse LaTeX AST: d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.472][Cacher] Parsed LaTeX AST in 4.57 ms: d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.472][File] kpsewhich cache hit on article.cls: f:/texlive/2024/texmf-dist/tex/latex/base/article.cls .
[17:05:43.473][Cacher] Updated elements in 0.79 ms: d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.473][Event] FILE_PARSED: "d:\\Downloads\\New folder (6)\\tst1.tex"
[17:05:43.474][Structure] Structure force updated with 0 root sections for d:\Downloads\New folder (6)\tst1.tex .
[17:05:43.475][Event] STRUCTURE_UPDATED
[17:05:43.503][Cacher] Parsing .fls d:\Downloads\New folder (6)\.latextmp\tst1.fls .
[17:05:43.547][Cacher] Found .aux d:\Downloads\New folder (6)\.latextmp\tst1.aux from .fls d:\Downloads\New folder (6)\.latextmp\tst1.fls , parsing.
[17:05:43.548][Cacher] Parsed .aux d:\Downloads\New folder (6)\.latextmp\tst1.aux .
[17:05:43.548][Cacher] Parsed .fls d:\Downloads\New folder (6)\.latextmp\tst1.fls .
[17:05:44.091][Linter] Linter for root successfully finished in 0s 676ms
[17:05:44.091][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[17:05:44.092][Linter][ChkTeX] Logged 0 messages.
[17:05:44.713][Commander] SYNCTEX command invoked.
[17:05:44.713][Locator] Forward from d:\Downloads\New folder (6)\tst1.tex to d:\Downloads\New folder (6)\.latextmp\tst1.pdf on line 5.
[17:05:44.740][Viewer] Try to synctex d:\Downloads\New folder (6)\.latextmp\tst1.pdf

### 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`._

25[Violation] Added non-passive event listener to a scroll-blocking event. Consider marking event handler as 'passive' to make the page more responsive. See console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:50.277Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:50.298Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:51.569Z', duration: 0, data: {…}} webviewElement.ts:482 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing. mountTo @ webviewElement.ts:482 P @ overlayWebview.ts:249 claim @ overlayWebview.ts:135 claim @ webviewEditorInput.ts:138 claim @ customEditorInput.ts:424 hb @ webviewEditor.ts:172 setInput @ webviewEditor.ts:163 await in setInput (async) S @ editorPanes.ts:434 L @ editorPanes.ts:254 openEditor @ editorPanes.ts:131 (anonymous) @ editorGroupView.ts:1269 Kb @ editorGroupView.ts:1293 Jb @ editorGroupView.ts:1251 openEditor @ editorGroupView.ts:1155 openEditor @ editorService.ts:573 await in openEditor (async) (anonymous) @ editorCommands.ts:488 invokeFunction @ instantiationService.ts:109 n @ commandService.ts:95 executeCommand @ commandService.ts:60 $executeCommand @ mainThreadCommands.ts:92 S @ rpcProtocol.ts:458 Q @ rpcProtocol.ts:443 M @ rpcProtocol.ts:373 L @ rpcProtocol.ts:299 (anonymous) @ rpcProtocol.ts:161 y @ event.ts:1196 fire @ event.ts:1227 fire @ ipc.net.ts:650 U.onmessage @ localProcessExtensionHost.ts:378 index.html?id=4f0213d4-390a-443d-b196-4524c851224f&origin=393bfc0c-c093-4664-ad67-bd3c11c9d905&swVersion=4&extensionId=James-Yu.latex-workshop&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1026 [Violation] Avoid using document.write(). https://developers.google.com/web/updates/2016/08/removing-document-write (anonymous) @ index.html?id=4f0213d4-390a-443d-b196-4524c851224f&origin=393bfc0c-c093-4664-ad67-bd3c11c9d905&swVersion=4&extensionId=James-Yu.latex-workshop&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1026 console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:53.226Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:53.237Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:54.618Z', duration: 0, data: {…}} webviewElement.ts:482 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing. mountTo @ webviewElement.ts:482 P @ overlayWebview.ts:249 claim @ overlayWebview.ts:135 claim @ webviewEditorInput.ts:138 claim @ customEditorInput.ts:424 hb @ webviewEditor.ts:172 setInput @ webviewEditor.ts:163 await in setInput (async) S @ editorPanes.ts:434 L @ editorPanes.ts:254 openEditor @ editorPanes.ts:131 (anonymous) @ editorGroupView.ts:1269 Kb @ editorGroupView.ts:1293 Jb @ editorGroupView.ts:1251 openEditor @ editorGroupView.ts:1155 openEditor @ editorService.ts:573 await in openEditor (async) (anonymous) @ editorCommands.ts:488 invokeFunction @ instantiationService.ts:109 n @ commandService.ts:95 executeCommand @ commandService.ts:60 $executeCommand @ mainThreadCommands.ts:92 S @ rpcProtocol.ts:458 Q @ rpcProtocol.ts:443 M @ rpcProtocol.ts:373 L @ rpcProtocol.ts:299 (anonymous) @ rpcProtocol.ts:161 y @ event.ts:1196 fire @ event.ts:1227 fire @ ipc.net.ts:650 U.onmessage @ localProcessExtensionHost.ts:378 index.html?id=50ff6524-dd1e-45e2-b727-0994c701d3c3&origin=393bfc0c-c093-4664-ad67-bd3c11c9d905&swVersion=4&extensionId=James-Yu.latex-workshop&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1026 [Violation] Avoid using document.write(). https://developers.google.com/web/updates/2016/08/removing-document-write (anonymous) @ index.html?id=50ff6524-dd1e-45e2-b727-0994c701d3c3&origin=393bfc0c-c093-4664-ad67-bd3c11c9d905&swVersion=4&extensionId=James-Yu.latex-workshop&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1026 console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:56.087Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:56.097Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:58.875Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:58.903Z', duration: 0, data: {…}} console.ts:137 [Extension Host] Sent heartbeat {timestamp: '2024-06-27T22:17:58.955Z', duration: 0, data: {…}}



## Anything Else?
> _Add any other context about the problem below._
- If I press "View LaTeX Pdf file", it does activate the one on the right, and then synctex works fine.
James-Yu commented 2 weeks ago

May you help check if this issue is a regression of version 10, or one that has been buggy in v9.x?

quoc-ho commented 2 weeks ago

I've encountered this issue for quite a while. It's a problem, for example, on v9.21.1.

xuezes commented 2 weeks ago

May you help check if this issue is a regression of version 10, or one that has been buggy in v9.x?

I've encountered this issue for quite a while. It's a problem, for example, on v9.21.1.

I've temporarily rolled back to v9.20.0, and it also got the same issue.