texstudio
texstudio copied to clipboard
autogenerated cwl and regular highlighter have issue with spaces
Environment
- TeXstudio: 4.3.0beta3
- Qt: 6.3.0
- OS: Windows 10
- TeX distribution: miktex
Expected behavior
It's increasingly common for package and class authors to use spaces in their code to make it more readable (see acro
, tabularray
, ctex
, and so on for examples).
Actual behavior
This causes both the autogenerated cwl and regular in-document highlighting to fail in some cases. For example the class file myclass.cls
% myclass.cls
\ProvidesExplClass {myclass} {2022-07-29} {v1} {custom class}
\LoadClass { book }
\RequirePackage { etoolbox }
\NewDocumentCommand{\foo}{m}{stuff}
\NewDocumentCommand{ \varfoo }{ m }{stuff}
\NewDocumentCommand {\varvarfoo} {m} {stuff}
\NewDocumentCommand { \varvarvarfoo } { m } {stuff}
\NewDocumentCommand\foovar{m}{stuff}
\NewDocumentCommand \foovarvar { m } {stuff}
produces the autogenerated cwl
# autogenerated by txs
#include:etoolbox
\foovarvar{arg1}#S
\foovar{arg1}#S
\foo{arg1}#S
\varvarfoo{arg1}#S
It does not recognize the \LoadClass
because of the spaces, but does recognize the \RequirePackage
even though it uses the same pattern of spaces. Also, \NewDocumentCommand
is not recognized if followed by either "{-space" or "space-{-space".
The same pattern holds for the completer if given in a .tex file, e.g.
![Screenshot 2022-07-29 111014](https://user-images.githubusercontent.com/61854785/181809923-82adefab-03ea-4288-9f04-7d2fb1f5636e.png)
Here's the source for this example:
\documentclass{article}
\NewDocumentCommand{ \mycmd } { } {stuff}
\NewDocumentCommand { \varmycmd } { } {stuff}
\begin{document}
\mycmd
\varmycmd
\end{document}