Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmatched \end{environment} in \newcommand #3101

Closed
hippalectryon-0 opened this issue Jun 2, 2023 · 4 comments · Fixed by #3482
Closed

Unmatched \end{environment} in \newcommand #3101

hippalectryon-0 opened this issue Jun 2, 2023 · 4 comments · Fixed by #3482
Assignees
Labels
bug Deficiencies in TeXiFy behaviour. parser Issues for which significant changes in the parser are needed
Milestone

Comments

@hippalectryon-0
Copy link

Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version

PyCharm 2023.1.2

Operating System

Ubuntu 22

TeXiFy IDEA version

0.7.30

What I did (steps to reproduce)

When creating a command that closes a block without opening it, the inspection raises an error (which in itself is understandable, as a warning at least), but this messes up the inspection of the blocks after the defined command.

Minimal example to reproduce the problem

In this example, the error is raised in the first command, and as a result subsequent commands fail to recognize their arguments

\newcommand{\closemulticol}[0]{  % Error "<key val key>, <required param content> or LatexTokenType.CLOSE_BRACE expected, got '\end'"
	\end{multicols}
}

\newcommand{\mycommand}[1]{#1}  % Warning "unescaped #"

Expected behavior

It's natural that a warning is raised in the command, as it's unusual that a command closes a block without opening it. However, it shouldn't mess up the inspection of subsequent commands.

@hippalectryon-0 hippalectryon-0 added bug Deficiencies in TeXiFy behaviour. untriaged Issue type still needs to be triaged or verified. labels Jun 2, 2023
@jojo2357
Copy link
Contributor

jojo2357 commented Jun 2, 2023

Well IJ does the same thing if you have an extra } in java, so Im not sure there is anything to be done here, but ill let @PHPirates chime in

@PHPirates
Copy link
Collaborator

PHPirates commented Jun 4, 2023

I know that this is perfectly valid LaTeX, but I'm not yet convinced that we should allow this. We can allow this in the parser, just like we do with e.g. \pretitle, but then of course you lose all (math) environment features like: indenting, environment rename, math highlighting (also inline math) and autocompletion. (That is, assuming we do want to keep a missing \end as a parse error. Maybe we can use a token remapper?)

@hippalectryon-0 could you give a use case for this, why you think this is good LaTeX style? In particular, why are you not using \newenvironment to define your own version of multicols?

@PHPirates PHPirates added more-info-needed More information is needed from the person filing the issue. and removed bug Deficiencies in TeXiFy behaviour. untriaged Issue type still needs to be triaged or verified. labels Jun 4, 2023
@hippalectryon-0
Copy link
Author

hippalectryon-0 commented Jun 6, 2023

Our use case was a modifier that inserted an object in an existing table:

\newcommand{\tableMod}[0]{
	\end{multicols}
	\insertedObject
	\begin{multicols}{2}
}

@PHPirates
Copy link
Collaborator

That makes sense, thanks. I will see what we can do

@PHPirates PHPirates changed the title End of part during command breaks inspection Unmatched \end{environment} in \newcommand Jun 7, 2023
@PHPirates PHPirates added bug Deficiencies in TeXiFy behaviour. parser Issues for which significant changes in the parser are needed and removed more-info-needed More information is needed from the person filing the issue. labels Jun 7, 2023
@PHPirates PHPirates added this to the Next milestone Mar 1, 2024
@PHPirates PHPirates self-assigned this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Deficiencies in TeXiFy behaviour. parser Issues for which significant changes in the parser are needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants