valentjn / vscode-ltex

LTeX: Grammar/spell checker :mag::heavy_check_mark: for VS Code using LanguageTool with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
817 stars 29 forks source link

False Positive in COMMA_PARENTHESIS_WHITESPACE in conjunction with macro #828

Open Reissner opened 1 year ago

Reissner commented 1 year ago

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.

Additional context/information None.

gilcu3 commented 1 year ago

I can confirm this happens on my environment as well

jonasc commented 1 year ago

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

hsiuhsiu commented 9 months ago

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.