texstudio
texstudio copied to clipboard
key arguments in a verbatim cwl definition are not recognized
Environment
- TeXstudio: 4.2.2
- Qt: 5.15.2
- OS: Linux (Fedora 35)
- TeX distribution: texlive
Expected behavior
All argument that are defined as "key%labeldef" in a cwl file should occur in a \ref command.
Actual behavior
In the test package there are two environments: "testEnv" and "testEnvVerbatim". They only differ in the definition of the cwl and the cwl definitions only differ such that for testEnvVerbatim the verbatim flag "#V" is set.
In the auto completion of \ref only testKey is shown and not testKeyVerbatim
As you can also the in the picture the arguments for testEnvVerbatim are also colored blue. Maybe this is connected with the error.
How to reproduce
Install the test package and the cwl file and open the cwlBug.tex file in TexStudio. Try to complete the \ref command.
I consider the first case already a corner case and the second (verbatim) a FR for special parsing. Unlikely that that will happen soon.
Why is the first one a corner case? Usually the parsing should nearly be the same, so I am wondering why the second case should be so different?
because unlike other commands, begin/end form a block ...
Yes, begin and end form a block, but the parsing of arguments should still be the same for all commands and begin/end blocks?
It is your own definition which uses this set-up, not a general latex package, right ?
Yes, it is a block that uses a minted block in a listing the real code is:
\newminted[code]{cpp}{
mathescape,
gobble=0,
fontsize=\small,
frame=single,
beameroverlays=true,
escapeinside=||
}
\newmintinline[ic]{cpp}{}
\newenvironment{codeRef}[3][H]
{\VerbatimEnvironment
\begin{listing}[#1]
\caption{#3}
\label{#2}
\begin{code}}
{\end{code}
\end{listing}}
\newenvironment{codeRefInline}[2]
{\VerbatimEnvironment
\begin{listing}[H]
\caption{#2}
\label{#1}
\begin{code}}
{\end{code}
\vspace*{-1.5em}
\end{listing}
\vspace*{-1em}
\noindent}
But also for the minted block the arguments are also highlighted in the color of the verbatim environment.
maybe to give some background, why I consider this a corner case:
txs parses commands, it can handle optional arguments but assumes that the number of mandatory arguments is fixed.
\begin
violates that assumption at several places, so there are some adaptions for that. The issue is that not only the number arguments is flexible but also dependent on the content of one argument (env name). Luckily this is not often a real issue, but I have no inclination to extend the parser to all kind of special cases.