Hi all,

This patch gives the user the possibility to finish a prematurily finalized macro.

The first part makes sure that no undo is recorded when a macro is edited, or, when a macro is resumed. The second part replaces the existing (finalized) MathMacro by a new MathUnknownInset, which is not yet finalized.

Is there anyone with some knowledge about Math willing to have a look ?

PS. This fixes bugs 5540 and 5923.
http://www.lyx.org/trac/ticket/5540
http://www.lyx.org/trac/ticket/5923

Vincent
Index: src/mathed/InsetMathNest.cpp
===================================================================
--- src/mathed/InsetMathNest.cpp        (revision 29669)
+++ src/mathed/InsetMathNest.cpp        (working copy)
@@ -816,8 +816,14 @@
                // InsetMathFrac -> a pos value > 0 is invalid.
                // A side effect is that an undo before the macro is finished
                // undoes the complete macro, not only the last character.
-               if (!cur.inMacroMode())
-                       cur.recordUndoSelection();
+               if (!cur.inMacroMode()) {
+                       MathMacro const * macro = 0;
+                       if (cur.pos() > 0 && cmd.argument() != "\\")
+                               macro = cur.inset().asInsetMath()->asMacro();
+                       
+                       if (!macro)
+                               cur.recordUndoSelection();
+               }
 
                // spacial handling of space. If we insert an inset
                // via macro mode, we want to put the cursor inside it
@@ -1556,6 +1562,19 @@
                return true;
        }
 
+       if (cur.pos() > 0) {
+               MathMacro const * macro = cur.inset().asInsetMath()->asMacro();
+               if (macro) {
+                       // resume macro_mode
+                       docstring const & s = macro->name();
+                       cur.leaveInset(*macro);
+                       cur.plainErase();
+                       docstring safe = grabAndEraseSelection(cur);
+                       cur.insert(MathAtom(new InsetMathUnknown("\\" + s + c, 
safe, false)));
+                       return true;    
+               }
+       }
+
        selClearOrDel(cur);
 
        if (c == '\n') {

Reply via email to