texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.82k stars 345 forks source link

brace mismatch with \directlua #2859

Open mbertucci47 opened 1 year ago

mbertucci47 commented 1 year ago

Environment

Expected behavior

The cwl entry for \directlua is \directlua{lua code%definition} with the %definition to prevent normal tex highlighting for the lua code.

Actual behavior

TXS colors the braces for \directlua and similar luatex commands like \latelua differently than it does for other commands with identical cwl specs. It also mismatches the braces even when the braces inside its arg are balanced.

Screenshot 2023-01-18 204530

The cwl specs are listed above the command. The \directlua line shows the highlighted mismatched braces, and the \latelua line shows the different coloring and matching. It seems to match the opening brace with the first closing brace it sees, but for some reason this only affects the luatex commands.

It also seems something weird is happening with the keywords "true" and "false" in \directlua, \latelua, etc.

tf

The equals sign is not important, any instance of "true" or "false" will be highlighted in orange (in my settings that's verbatim text).

How to reproduce

\documentclass{article}

\usepackage{luatexbase} % for #include:luatex so \directlua,\latelua,...
\usepackage{pythonimmediate} % for \py

\begin{document}

% \directlua{lua code%definition}
\directlua{fonts.protrusions.setups.goridot = {[0x3002] = { 0, 0.5 },}}
% \latelua{lua code%definition}
\latelua{fonts.protrusions.setups.goridot = {[0x3002] = { 0, 0.5 },}}
% \newcommand{cmd}{def}
\newcommand{\mystring}{fonts.protrusions.setups.goridot = {[0x3002] = { 0, 0.5 },}}
% \fpeval{fp expression%definition}
\fpeval{fonts.protrusions.setups.goridot = {[0x3002] = { 0, 0.5 },}}
% cwl entry \py{python expr%definition}
\py{fonts.protrusions.setups.goridot = {[0x3002] = { 0, 0.5 },}}

\directlua{true/sdfgdf}
\directlua{bla=false}
\directlua{bla=something}
\latelua{bla=true}
\end{document}
sunderme commented 1 year ago

seems an issue with lua.qnfa/ tex.qnfa. Maybe there is a simple solution, but probably not.