Closed tobiscode closed 3 years ago
It is weird, I cannot reproduce the issue even with a line longer than 3000 characters. The line number is correct but the column number is wrong. I use chktex-1.7.6
from TexLive 2021.
I am afraid it is out of the scope of this extension to implement tricks to bypass a chktex
bug. Note that you can always deactivate automatic linting "latex-workshop.chktex.enabled": false
.
Interesting - I also have ChkTeX v1.7.6
. So maybe there is a difference between TexLive and MikTeX?..
I do understand though in this case that this is out of scope (even if I think just deactivating ChkTeX in the extension settings isn't an actual workaround).
Anyway, I hope me posting this here at least helps others facing the same problem, and maybe someone with more C or TS coding experience will get just as annoyed at this as me to have a closer look 😉
Edit: just installed TeX Live 2021/W32TeX and the problem is the same. So maybe it's a Windows vs. Mac/Unix thing then?... This is what both give for xhktex --version
:
ChkTeX v1.7.6 - Copyright 1995-96 Jens T. Berger Thielemann.
Compiled with POSIX extended regex support.
Edit 2: Yep, can confirm this problem doesn't happen on either a dedicated Linux or even WSL Linux...
ChkTeX: warn of lines that are too long and therefore generate erroneous warnings
Preliminary questions
✔ Disable all the other extensions except for LaTeX Workshop, restart VS Code, and check that you can not see the requested feature. [Required] You still see this issue? Yes. ✔ Make sure to visit the wiki FAQ before requesting a feature. You visited the wiki? Yes. ✔
If your requested feature is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.Not a compilation problem. ✔ Are you using VSCodium? No. ✔ Are you using the Snap or Flatpack versions of VS Code? No. ✔ Are you using LaTeX Workshop with VS Code Remote? No.Is your requested feature related to a problem? Please describe.
When writing long sentences, especially when using lots of long commands, I've noticed that I sometimes got erroneous but serious-sounding warnings in the problem panel through ChkTeX, e.g. missing command brackets. Because compilation always worked fine, I got confused why ChkTeX would complain. I wasted a lot of time trying to figure it out, until I ran ChkTeX myself from the command line, which told me that ChkTeX has problems with long lines, and apparently just gives up linting. The LaTeX Workshop actually also relays this:
Now, since it's a long file, with many long lines, I had no idea where to look, so narrowing down the culprit line took some more time as well.
To reproduce
This minimal TeX file compiles and shows the problem:
On the problem panel, I get:
And running ChkTeX manually, I see that it ends parsing the line in the middle of the command:
And when the parser ends between the curly brackets, the warning will be that there is a bracket missing.
Describe the solution you'd like
In any case, what I did for myself, was to hack together a VS Code extension that just checks the currently open file for long lines, and writes the line numbers to a new output window, where I guess the relevant parts are:
(Sorry for the bad TypeScript, this is literally the first time I tried this language.)
(Through my internet search, it actually turns out that the limit of 509 bytes in my case is actually not uniform, since it depends on the compilation parameters of ChkTeX, and I read that other users on the interwebs have it at 1024 bytes, so depending on that reproducers might need to add more characters.)
The code gives me:
This finally helped me find the lines in my source file that were too long.
It looks easy enough to integrate a similar option into the LaTeX Workshop, probably not scanning the file directly but using something like VS Code's
getText
function, and not creating a new output panel every time... And probably there's a much easier way to just add the warning or info into the problem panel instead an output console so that everything is neatly in one place.A maybe even easier, although less informative thing one could do is to check for this particular message (see the log at the top) while parsing ChkTeX's error code and return message (which LaTeX Workshop does anyway), and then just put a generic warning into the problem panel that this is something the user should check if they see erroneous warnings. That avoids the document parsing, but still helps the user not go down the rabbit hole trying to find non-existent problems in their LaTeX file.
Logs
LaTeX Workshop Output
Developer Tools Console
This is probably unrelated but still (only message in dev console):
Desktop