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

Disallow unmatched braces after \@ifnextchar #3775

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

### Fixed
* Disallow unmatched braces after \@ifnextchar

## [0.9.9-alpha.8] - 2024-11-28

Expand Down
3 changes: 2 additions & 1 deletion src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ WHITE_SPACE={SINGLE_WHITE_SPACE}+
// Commands
BEGIN_TOKEN="\\begin"
END_TOKEN="\\end"
COMMAND_IFNEXTCHAR=\\@ifnextchar.
// All characters after @ifnextchar may be unbalanced, except braces, see https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/3744#issuecomment-2477263416
COMMAND_IFNEXTCHAR=\\@ifnextchar[^{]
COMMAND_TOKEN=\\([a-zA-Z@]+|.|\r)
COMMAND_TOKEN_LATEX3=\\([a-zA-Z@_:0-9]+|.|\r) // _ and : are only LaTeX3 syntax
LATEX3_ON=\\(ExplSyntaxOn|ProvidesExplPackage|ProvidesExplClass|ProvidesExplFile)
Expand Down
2 changes: 2 additions & 0 deletions test/nl/hannahsten/texifyidea/psi/LatexParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class LatexParserTest : BasePlatformTestCase() {
"""
\newcommand{\xyz}{\@ifnextchar[{\@xyz}{\@xyz[default]}}
\def\@xyz[#1]#2{do something with #1 and #2}

\@namedef{#1}{\@ifnextchar{^}{\@nameuse{#1@}}{\@nameuse{#1@}^{}}}
""".trimIndent()
)
myFixture.checkHighlighting()
Expand Down
Loading