[LyX/master] Do not allow nesting macro names in macro names
Enrico Forestieri
forenr at lyx.org
Mon Nov 21 16:34:57 UTC 2022
commit 1ac2dc208238a28c95275117e2bc90ea651bdf36
Author: Enrico Forestieri <forenr at lyx.org>
Date: Mon Nov 21 18:24:29 2022 +0100
Do not allow nesting macro names in macro names
LyX removes a single backslash when it is inserted in a
macro name by the keyboard. However if it is followed by
another character before moving the cursor, it is retained
causing an assertion (bug #12601).
---
src/mathed/InsetMathNest.cpp | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 70ef185..673a62d 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -1825,9 +1825,15 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
//lyxerr << "starting with macro" << endl;
bool reduced = cap::reduceSelectionToOneCell(cur);
if (reduced || !cur.selection()) {
+ InsetMath const * im = cur.inset().asInsetMath();
+ InsetMathMacro const * macro = im ? im->asMacro()
+ : nullptr;
+ bool in_macro_name = macro
+ && macro->displayMode() ==
+ InsetMathMacro::DISPLAY_UNFOLDED;
cur.recordUndoInset();
docstring const safe = cap::grabAndEraseSelection(cur);
- if (!cur.inRegexped())
+ if (!cur.inRegexped() && !in_macro_name)
cur.insert(MathAtom(new InsetMathUnknown(from_ascii("\\"), safe, false)));
else
cur.niceInsert(createInsetMath("backslash", buf));
More information about the lyx-cvs
mailing list