texstudio icon indicating copy to clipboard operation
texstudio copied to clipboard

key arguments in a verbatim cwl definition are not recognized

Open MaxSagebaum opened this issue 2 years ago • 7 comments

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

cwlError

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.

test_cwl.txt test_sty.txt cwlBug_tex.txt

MaxSagebaum avatar May 05 '22 12:05 MaxSagebaum

I consider the first case already a corner case and the second (verbatim) a FR for special parsing. Unlikely that that will happen soon.

sunderme avatar May 05 '22 16:05 sunderme

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?

MaxSagebaum avatar May 05 '22 17:05 MaxSagebaum

because unlike other commands, begin/end form a block ...

sunderme avatar May 05 '22 19:05 sunderme

Yes, begin and end form a block, but the parsing of arguments should still be the same for all commands and begin/end blocks?

MaxSagebaum avatar May 06 '22 06:05 MaxSagebaum

It is your own definition which uses this set-up, not a general latex package, right ?

sunderme avatar May 06 '22 15:05 sunderme

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.

MaxSagebaum avatar May 06 '22 16:05 MaxSagebaum

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.

sunderme avatar May 08 '22 14:05 sunderme