vscode-ltex icon indicating copy to clipboard operation
vscode-ltex copied to clipboard

False Positive in COMMA_PARENTHESIS_WHITESPACE in conjunction with macro

Open Reissner opened this issue 1 year ago • 3 comments

Describe the bug \newcommand{\test}{\texttt{test}} \newcommand{\notest}{\texttt{no test}} Example: Consider \test, but not \notest.

This yields two warnings at the macros both COMMA_PARENTHESIS_WHITESPACE with slightly different text: \test: Put a space after the comma, but not before (the comma). \notest: Don't put a space before the full stop.

In both cases, the macro seems just to be ignored.

Steps to reproduce Steps to reproduce the behavior:

  1. Make a tex-file with the above line.
  2. Activate ltex
  3. See errors

Expected behavior As one cannot know what the macro really does, may also be invisible, one shall not check when a macro is present. Conceivable also to assume, it is non-empty text and risk false positives.

I think, "\test " is rarely ok, whereas "\test," and "\test," and that like are (macro followed by mark). So maybe for macros we need another type of whitespace check.

Sample document Too simple.

LTeX configuration No file settings.json. "LTeX Language Server" log file Nothing referring to the problem

"LTeX Language Client" log file Nothing referring to the problem

Version information List here the version information of the relevant software.

  • Operating system: Linux (which distribution/version), macOS xx.xx, or Windows xx
  • VS Code: 1.65.0
  • vscode-ltex: 13.1.0
  • ltex-ls: x.xx (only if not using ltex-ls automatically downloaded by LTeX)
  • Java: x.xx (usually obtained with java -version, only if not using Java automatically downloaded by LTeX)

Additional context/information None.

Reissner avatar Mar 11 '23 09:03 Reissner

I can confirm this happens on my environment as well

gilcu3 avatar May 14 '23 08:05 gilcu3

This can be (temporarily?) mitigated by adding both \test and \notest to the ltex.latex.commands setting with type dummy.

jonasc avatar Jun 06 '23 14:06 jonasc

This can be (temporarily?) mitigated by adding both \test and \notest to the ltex.latex.commands setting with type dummy.

This is super helpful!! Thank you @jonasc Also, I think this is better than a "temporarily solution", as users can have arbitrary macros and it make sense for them to be in charge to telling ltex how to parse them.

hsiuhsiu avatar Feb 27 '24 22:02 hsiuhsiu