[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
Operating System: Debian trixie
Visual Studio Code Version: 1.94.2
LaTeX Workshop Version: 10.5.5
TeX Distribution Version: texlive 2024.20240829
The Issue
Looking further into my local error behind #4445 (the broken links for \cite keys), I noticed a bibtex syntax error in line ~900 which is correct with biber:
% @misc{foobar,
@misc{test,
author = {Test},
title = {Test},
}
This is hopefully an uncommon problem, but it left me really confused for way too long. The problem is that LM uses latex-utensils's bibtex parser, whereas the rest of my (and any reasonably modern configuration) uses biblatex/biber.
Comments are only supported in biber, so the bibtex parser finds the @ in the first line and chokes with a SyntaxError. No error is reported via Diagnostics, but the extension registers 0 entries from the bib file. The only indication something went wrong somewhere is a stack trace in the LaTeX Workshop logger:
SyntaxError: Expected "%", "}", [ \t\r\n], or [^%@={}()"#, \t\r\n] but "@" found.
at new peg$SyntaxError (~/.vscode/extensions/james-yu.latex-workshop-10.5.5/node_modules/latex-utensils/out/src/bibtex/bibtex_parser_simple.js:14:20)
at peg$buildStructuredError (~/.vscode/extensions/james-yu.latex-workshop-10.5.5/node_modules/latex-utensils/out/src/bibtex/bibtex_parser_simple.js:446:12)
at Object.peg$parse [as parse] (~/.vscode/extensions/james-yu.latex-workshop-10.5.5/node_modules/latex-utensils/out/src/bibtex/bibtex_parser_simple.js:1982:11)
at Object.parse (~/.vscode/extensions/james-yu.latex-workshop-10.5.5/node_modules/latex-utensils/out/src/bibtex/bibtex_parser.js:36:30)
at Function.parseBibTeX (~/.vscode/extensions/james-yu.latex-workshop-10.5.5/out/src/parse/parser/unified.js:47:46)
at MessagePort.<anonymous> (~/.vscode/extensions/james-yu.latex-workshop-10.5.5/node_modules/workerpool/src/worker.js:150:27)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Notice that no location information is printed, although the SyntaxError exception provides a location field. I managed to patch in the information around here through
which helped a lot to address multiple such tiny issues and after all were resolved citation linking magically worked again. :cake:
A few hours of getting used to the code base were not enough to address this in a reasonable way, so I will have to leave it to upstream to address this properly. My main show stopper for a PR was that I tried to add diagnostic messages (with a few structural changes) by returning SyntaxErrorfrom here, but the non-Error data fields do not survive serialization because of the async await and location will be undefined.
Reproduction Steps
create this `literature.bib`
```
% @misc{test,
@misc{test,
author = {Test},
title = {Test},
}
```
and this `main.tex`
```
\documentclass{minimal}
\usepackage{biblatex}
\addbibresource{literature.bib}
\begin{document}
test~\cite{test}
\end{document}
```
CTRL + mouse over on the key of \cite{test} will not create the link in test and a SyntaxError will be logged in the extensions output.
remove the @ behind % in the first line in in literature.bib
now the link will work as expected
Expected Behavior
Either the extension should detect whether bibtex or biber is used and parse files differently depending on that
or the SyntaxError should be promoted to a Diagnostic error message and the user should be encouraged to resolve the error by making their bib files bibtex compatible.
The current behavior of almost silent failure of a core feature on unreported syntax errors is very problematic either way
Sorry for the long issue description, it took quite some investigation.
Pre-checks
Environment
The Issue
Looking further into my local error behind #4445 (the broken links for \cite keys), I noticed a bibtex syntax error in line ~900 which is correct with biber:
This is hopefully an uncommon problem, but it left me really confused for way too long. The problem is that LM uses latex-utensils's bibtex parser, whereas the rest of my (and any reasonably modern configuration) uses biblatex/biber. Comments are only supported in biber, so the bibtex parser finds the @ in the first line and chokes with a
SyntaxError
. No error is reported via Diagnostics, but the extension registers 0 entries from the bib file. The only indication something went wrong somewhere is a stack trace in the LaTeX Workshop logger:Notice that no location information is printed, although the SyntaxError exception provides a
location
field. I managed to patch in the information around here throughwhich helped a lot to address multiple such tiny issues and after all were resolved citation linking magically worked again. :cake:
A few hours of getting used to the code base were not enough to address this in a reasonable way, so I will have to leave it to upstream to address this properly. My main show stopper for a PR was that I tried to add diagnostic messages (with a few structural changes) by returning
SyntaxError
from here, but the non-Error data fields do not survive serialization because of the async await andlocation
will be undefined.Reproduction Steps
create this `literature.bib`
``` % @misc{test, @misc{test, author = {Test}, title = {Test}, } ```and this `main.tex`
``` \documentclass{minimal} \usepackage{biblatex} \addbibresource{literature.bib} \begin{document} test~\cite{test} \end{document} ```\cite{test}
will not create the link intest
and a SyntaxError will be logged in the extensions output.@
behind%
in the first line in inliterature.bib
Expected Behavior
Sorry for the long issue description, it took quite some investigation.