James-Yu / LaTeX-Workshop

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

PDF Viewer scrolls back to first page on every update #3733

Closed fbbdev closed 1 year ago

fbbdev commented 1 year ago

Pre-checks

Environment

The Issue

Reproduction Steps

  1. Create a LuaLaTeX project with at least two or three pages worth of content
  2. Compile the project with the command latexmk -pdflua -outdir=build toplevelFileName
  3. Open the generated PDF in the internal viewer and scroll to the last page
  4. Modify the source code and recompile with the same command as in step 2

At this point the PDF viewer updates and scrolls back to the first page.

Expected Behavior

Logs

LaTeX Workshop Output

[10:24:46][Logger] New log placeholder %WS1% registered for /Users/fabio/Desktop/Just LK Things/refutation games 3 .
[10:24:46][Config] Configuration for workspace: file://%WS1% .
[10:24:46][Config] editor.acceptSuggestionOnEnter: "on" .
[10:24:46][Config] latex-workshop.bind.enter.key: true .
[10:24:46][Config] latex-workshop.docker.enabled: false .
[10:24:46][Config] latex-workshop.docker.image.latex: "" .
[10:24:46][Config] latex-workshop.hover.preview.mathjax.extensions: [] .
[10:24:46][Config] latex-workshop.intellisense.package.enabled: true .
[10:24:46][Config] latex-workshop.intellisense.update.aggressive.enabled: false .
[10:24:46][Config] latex-workshop.intellisense.update.delay: 1000 .
[10:24:46][Config] latex-workshop.latex.autoBuild.run: "never" .
[10:24:46][Config] latex-workshop.latex.build.forceRecipeUsage: true .
[10:24:46][Config] latex-workshop.latex.outDir: "%WORKSPACE_FOLDER%/build" .
[10:24:46][Config] latex-workshop.latex.recipes: [
 {
  "name": "latexmk 🔃",
  "tools": [
   "latexmk"
  ]
 },
 {
  "name": "latexmk (latexmkrc)",
  "tools": [
   "latexmk_rconly"
  ]
 },
 {
  "name": "latexmk (lualatex)",
  "tools": [
   "lualatexmk"
  ]
 },
 {
  "name": "pdflatex ➞ bibtex ➞ pdflatex × 2",
  "tools": [
   "pdflatex",
   "bibtex",
   "pdflatex",
   "pdflatex"
  ]
 },
 {
  "name": "Compile Rnw files",
  "tools": [
   "rnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "Compile Jnw files",
  "tools": [
   "jnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "tectonic",
  "tools": [
   "tectonic"
  ]
 }
] .
[10:24:46][Config] latex-workshop.latex.tools: [
 {
  "name": "latexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-pdf",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "lualatexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-lualatex",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "xelatexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-xelatex",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "latexmk_rconly",
  "command": "latexmk",
  "args": [
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "pdflatex",
  "command": "pdflatex",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "bibtex",
  "command": "bibtex",
  "args": [
   "%DOCFILE%"
  ],
  "env": {}
 },
 {
  "name": "rnw2tex",
  "command": "Rscript",
  "args": [
   "-e",
   "knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"
  ],
  "env": {}
 },
 {
  "name": "jnw2tex",
  "command": "julia",
  "args": [
   "-e",
   "using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"
  ],
  "env": {}
 },
 {
  "name": "jnw2texminted",
  "command": "julia",
  "args": [
   "-e",
   "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"
  ],
  "env": {}
 },
 {
  "name": "pnw2tex",
  "command": "pweave",
  "args": [
   "-f",
   "tex",
   "%DOC_EXT%"
  ],
  "env": {}
 },
 {
  "name": "pnw2texminted",
  "command": "pweave",
  "args": [
   "-f",
   "texminted",
   "%DOC_EXT%"
  ],
  "env": {}
 },
 {
  "name": "tectonic",
  "command": "tectonic",
  "args": [
   "--synctex",
   "--keep-logs",
   "%DOC%.tex"
  ],
  "env": {}
 }
] .
[10:24:46][Config] latex-workshop.viewer.pdf.internal.keyboardEvent: "auto" .
[10:24:46][Manager] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[10:24:46][Server] Creating LaTeX Workshop http and websocket server.
[10:24:46][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":61114} .
[10:24:46][Extension] Initializing LaTeX Workshop.
[10:24:46][Extension] Extension root: /Users/fabio/.vscode/extensions/james-yu.latex-workshop-9.7.0
[10:24:46][Extension] $PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/fabio/.deno/bin:/Users/fabio/.cargo/bin:/Users/fabio/.local/bin
[10:24:46][Extension] $SHELL: /bin/zsh
[10:24:46][Extension] $LANG: en_US.UTF-8
[10:24:46][Extension] $LC_ALL: en_US.UTF-8
[10:24:46][Extension] process.platform: darwin
[10:24:46][Extension] process.arch: x64
[10:24:46][Extension] vscode.env.appName: Visual Studio Code
[10:24:46][Extension] vscode.env.remoteName: undefined
[10:24:46][Extension] vscode.env.uiKind: 1
[10:24:46][Extension] LaTeX Workshop initialized.
[10:24:46][Format][Bib] Bibtex format config: {"tab":"    ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[10:24:46][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[10:24:46][Manager] Current workspace folders: ["file://%WS1%"]
[10:24:46][Manager] Found root file from active editor: %WS1%/refutation.tex
[10:24:46][Manager] Root file changed: from undefined to %WS1%/refutation.tex
[10:24:46][Manager] Start to find all dependencies.
[10:24:46][Manager] Root file languageId: latex
[10:24:46][Cacher][Watcher] Reset.
[10:24:46][Cacher] Adding %WS1%/refutation.tex .
[10:24:46][Cacher][Watcher] Watched %WS1%/refutation.tex with a new watcher on %WS1% .
[10:24:46][Cacher] Caching %WS1%/refutation.tex .
[10:24:46][Cacher] Input %WS1%/config.tex from %WS1%/refutation.tex .
[10:24:46][Cacher] Adding %WS1%/config.tex .
[10:24:46][Cacher][Watcher] Watched %WS1%/config.tex .
[10:24:46][Cacher] Caching %WS1%/config.tex .
[10:24:46][Cacher] Updated inputs of %WS1%/config.tex .
[10:24:46][Cacher] Input %WS1%/commands.tex from %WS1%/refutation.tex .
[10:24:46][Cacher] Adding %WS1%/commands.tex .
[10:24:46][Cacher][Watcher] Watched %WS1%/commands.tex .
[10:24:46][Cacher] Caching %WS1%/commands.tex .
[10:24:46][Cacher] Updated inputs of %WS1%/commands.tex .
[10:24:46][Cacher] Input %WS1%/penalties.tex from %WS1%/refutation.tex .
[10:24:46][Cacher] Adding %WS1%/penalties.tex .
[10:24:46][Cacher][Watcher] Watched %WS1%/penalties.tex .
[10:24:46][Cacher] Caching %WS1%/penalties.tex .
[10:24:46][Cacher] Updated inputs of %WS1%/penalties.tex .
[10:24:46][Cacher] Updated inputs of %WS1%/refutation.tex .
[10:24:46][DupLabel] Checking for duplicate labels: %WS1%/config.tex .
[10:24:46][Cacher] Updated elements of %WS1%/config.tex .
[10:24:46][Cacher] Updated bibs of %WS1%/config.tex .
[10:24:46][Cacher] Cached %WS1%/config.tex .
[10:24:46][Server] valdOrigin is http://127.0.0.1:61114
[10:24:46][DupLabel] Checking for duplicate labels: %WS1%/commands.tex .
[10:24:46][Cacher] Updated elements of %WS1%/commands.tex .
[10:24:46][Cacher] Updated bibs of %WS1%/commands.tex .
[10:24:46][Cacher] Cached %WS1%/commands.tex .
[10:24:46][DupLabel] Checking for duplicate labels: %WS1%/penalties.tex .
[10:24:46][Cacher] Updated elements of %WS1%/penalties.tex .
[10:24:46][Cacher] Updated bibs of %WS1%/penalties.tex .
[10:24:46][Cacher] Cached %WS1%/penalties.tex .
[10:24:47][DupLabel] Checking for duplicate labels: %WS1%/refutation.tex .
[10:24:47][Cacher] Updated elements of %WS1%/refutation.tex .
[10:24:47][Cacher] Bib %WS1%/biblio.bib from %WS1%/refutation.tex .
[10:24:47][Intelli][Citation] Parsing .bib entries from %WS1%/biblio.bib
[10:24:47][Cacher][Watcher] Watched %WS1%/biblio.bib with a new watcher on %WS1% .
[10:24:47][Cacher] Updated bibs of %WS1%/refutation.tex .
[10:24:47][Cacher] Cached %WS1%/refutation.tex .
[10:24:47][Cacher] Parsing .fls %WS1%/build/refutation.fls .
[10:24:47][Cacher] Found .aux %WS1%/refutation.tex from .fls %WS1%/build/refutation.fls , parsing.
[10:24:47][Cacher] Parsed .aux %WS1%/refutation.tex .
[10:24:47][Cacher] Parsed .fls %WS1%/build/refutation.fls .
[10:24:47][Structure] Structure force updated with 6 root sections for %WS1%/refutation.tex .
[10:24:47][Intelli][Citation] Parsed 83 bib entries from %WS1%/biblio.bib .
[10:24:47][Structure] Structure force updated with 6 root sections for %WS1%/refutation.tex .
[10:24:48][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:61114/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRlVzZXJzJTJGZmFiaW8lMkZEZXNrdG9wJTJGSnVzdCUyMExLJTIwVGhpbmdzJTJGcmVmdXRhdGlvbiUyMGdhbWVzJTIwMyUyRmJ1aWxkJTJGcmVmdXRhdGlvbi5wZGY .
[10:24:48][Cacher][Watcher] Watched %WS1%/build/refutation.pdf with a new watcher on %WS1%/build .
[10:24:48][Viewer] Open PDF tab for file://%WS1%/build/refutation.pdf
[10:24:49][Viewer] Handle data type: open
[10:24:49][Server] Preview PDF file: file://%WS1%/build/refutation.pdf
[10:24:49][Viewer] Handle data type: loaded
[10:25:01][Extension] onDidSaveTextDocument triggered: file://%WS1%/refutation.tex
[10:25:01][Cacher][Watcher] "change" emitted on %WS1%/refutation.tex .
[10:25:01][Cacher] Caching %WS1%/refutation.tex .
[10:25:01][Cacher] Input %WS1%/config.tex from %WS1%/refutation.tex .
[10:25:01][Cacher] Input %WS1%/commands.tex from %WS1%/refutation.tex .
[10:25:01][Cacher] Input %WS1%/penalties.tex from %WS1%/refutation.tex .
[10:25:01][Cacher] Updated inputs of %WS1%/refutation.tex .
[10:25:01][DupLabel] Checking for duplicate labels: %WS1%/refutation.tex .
[10:25:01][Cacher] Updated elements of %WS1%/refutation.tex .
[10:25:01][Cacher] Bib %WS1%/biblio.bib from %WS1%/refutation.tex .
[10:25:01][Cacher] Updated bibs of %WS1%/refutation.tex .
[10:25:01][Cacher] Cached %WS1%/refutation.tex .
[10:25:01][Structure] Structure force updated with 6 root sections for %WS1%/refutation.tex .
[10:25:08][Cacher][Watcher] "change" emitted on %WS1%/build/refutation.pdf after polling for 252 ms.
[10:25:08][Viewer] Call refreshExistingViewer: "%WS1%/build/refutation.pdf" .
[10:25:08][Viewer] Refresh PDF viewer: %WS1%/build/refutation.pdf
[10:25:08][Server] Preview PDF file: file://%WS1%/build/refutation.pdf
[10:25:10][Cacher][Watcher] "change" emitted on %WS1%/build/refutation.pdf after polling for 252 ms.
[10:25:10][Viewer] Call refreshExistingViewer: "%WS1%/build/refutation.pdf" .
[10:25:10][Viewer] Refresh PDF viewer: %WS1%/build/refutation.pdf
[10:25:10][Server] Preview PDF file: file://%WS1%/build/refutation.pdf
[10:25:13][Extension] onDidSaveTextDocument triggered: file://%WS1%/refutation.tex
[10:25:13][Cacher][Watcher] "change" emitted on %WS1%/refutation.tex .
[10:25:13][Cacher] Caching %WS1%/refutation.tex .
[10:25:13][Cacher] Input %WS1%/config.tex from %WS1%/refutation.tex .
[10:25:13][Cacher] Input %WS1%/commands.tex from %WS1%/refutation.tex .
[10:25:13][Cacher] Input %WS1%/penalties.tex from %WS1%/refutation.tex .
[10:25:13][Cacher] Updated inputs of %WS1%/refutation.tex .
[10:25:13][DupLabel] Checking for duplicate labels: %WS1%/refutation.tex .
[10:25:13][Cacher] Updated elements of %WS1%/refutation.tex .
[10:25:13][Cacher] Bib %WS1%/biblio.bib from %WS1%/refutation.tex .
[10:25:13][Cacher] Updated bibs of %WS1%/refutation.tex .
[10:25:13][Cacher] Cached %WS1%/refutation.tex .
[10:25:13][Structure] Structure force updated with 6 root sections for %WS1%/refutation.tex .
[10:25:16][Viewer] Handle data type: loaded
[10:25:16][Viewer] Handle data type: loaded
[10:25:26][Cacher][Watcher] "change" emitted on %WS1%/build/refutation.pdf after polling for 251 ms.
[10:25:26][Viewer] Call refreshExistingViewer: "%WS1%/build/refutation.pdf" .
[10:25:26][Viewer] Refresh PDF viewer: %WS1%/build/refutation.pdf
[10:25:26][Server] Preview PDF file: file://%WS1%/build/refutation.pdf
[10:25:28][Cacher][Watcher] "change" emitted on %WS1%/build/refutation.pdf after polling for 253 ms.
[10:25:28][Viewer] Call refreshExistingViewer: "%WS1%/build/refutation.pdf" .
[10:25:28][Viewer] Refresh PDF viewer: %WS1%/build/refutation.pdf
[10:25:28][Server] Preview PDF file: file://%WS1%/build/refutation.pdf
[10:25:28][Viewer] Handle data type: loaded
[10:25:28][Viewer] Handle data type: loaded

Developer Tools Console

log.ts:398  WARN Via 'product.json#extensionEnabledApiProposals' extension 'github.vscode-pull-request-github' wants API proposal 'commentsResolvedState' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (check 'vscode.d.ts') or was abandoned.
log.ts:398  WARN [twxs.cmake]: Cannot register 'cmake.cmakePath'. This property is already registered.
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/james-yu.latex-workshop-9.7.0/syntax/TeX.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/james-yu.latex-workshop-9.7.0/syntax/LaTeX.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/james-yu.latex-workshop-9.7.0/syntax/Bibtex.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/james-yu.latex-workshop-9.7.0/syntax/markdown-latex-combined.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/james-yu.latex-workshop-9.7.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.macro.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/cpp/syntaxes/cpp.embedded.macro.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/jeff-hykin.better-cpp-syntax-1.17.2/autogenerated/cpp.embedded.macro.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope source.cpp.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/cpp/syntaxes/cpp.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/jeff-hykin.better-cpp-syntax-1.17.2/autogenerated/cpp.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope source.julia.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/julia/syntaxes/julia.tmLanguage.json.
New grammar file: file:///Users/fabio/.vscode/extensions/julialang.language-julia-1.38.2/syntaxes/julia_vscode.json
register @ TMScopeRegistry.ts:47
TaskQueue.ts:93 task queue exceeded allotted deadline by 21ms
_process @ TaskQueue.ts:93
log.ts:404   ERR Unable to load and parse grammar for scope source.liquid-attribute.injection from file:///Users/fabio/.vscode/extensions/sissel.shopify-liquid-3.2.2/syntax/injections/attribute.tmLanguage.json Error: Unable to read file '/Users/fabio/.vscode/extensions/sissel.shopify-liquid-3.2.2/syntax/injections/attribute.tmLanguage.json' (Error: Unable to resolve nonexistent file '/Users/fabio/.vscode/extensions/sissel.shopify-liquid-3.2.2/syntax/injections/attribute.tmLanguage.json')
    at l.w (fileService.ts:584:10)
    at l.v (fileService.ts:569:15)
    at async l.u (fileService.ts:481:18)
    at async S.readExtensionResource (extensionResourceLoaderService.ts:36:18)
    at async Object.loadGrammar (TMGrammarFactory.ts:54:22)
    at async t.Registry._doLoadSingleGrammar (main.js:82:15)
    at async Promise.all (index 2)
    at async t.Registry._loadGrammar (main.js:69:47)
    at async D.createGrammar (TMGrammarFactory.ts:141:14)
    at async Object.createTokenizationSupport (abstractTextMateService.ts:268:16)
    at async R.i (tokenizationRegistry.ts:146:17)
    at async D.getOrCreate (tokenizationRegistry.ts:72:3)
console.ts:137 [Extension Host] [vscode-icons] v12.2.0 activated!
log.ts:392  INFO [perf] Render performance baseline is 31ms
James-Yu commented 1 year ago

Strange enough, there is no [Build] logs in your provided information, meaning that neither manual nor auto-builds were triggered. This makes it hard to identify the exact cause.

If you also observed repeated refreshes of viewer with a very short interval (several hundred milliseconds), you may try to increase the value of latex-workshop.latex.watch.pdf.delay. Increasing this value will make the extension less sensitive to file changes, which in turn triggers PDF viewer refresh.

fbbdev commented 1 year ago

There are no Build logs because I am building with a custom makefile. Increasing the watch delay solved the issue, thank you.