]> git.lyx.org Git - features.git/commitdiff
Better fix for bug #5923. Now the macro name can be freely edited.
authorEnrico Forestieri <forenr@lyx.org>
Thu, 9 Jul 2009 15:21:21 +0000 (15:21 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 9 Jul 2009 15:21:21 +0000 (15:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30425 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/MathData.cpp
src/mathed/MathMacro.cpp

index ac74cca64a3a36583027e99dcfeb4baf96bc2364..7474632caeff1aa8f73c0b8d02aeaf07b7138e4c 100644 (file)
@@ -386,19 +386,6 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc)
                                || macroInset->name_[0] == '_')
                        continue;
 
-               if (macroInset->displayMode() == MathMacro::DISPLAY_UNFOLDED) {
-                       docstring const & unfolded_name = macroInset->name();
-                       if (unfolded_name != macroInset->name_) {
-                               // macro name was changed
-                               cur->recordUndoInset();
-                               cur->leaveInset(*macroInset);
-                               cur->plainErase();
-                               cur->insert(MathAtom(new InsetMathUnknown('\\'
-                                       + unfolded_name, docstring(), false)));
-                               continue;
-                       }
-               }
-               
                // get macro
                macroInset->updateMacro(mc);
                size_t macroNumArgs = 0;
index d5e31f6cdd7448f8ac5229875d20137566f65ef6..44ea1d49dc787975882f5c5133af2c2b44267736 100644 (file)
@@ -17,6 +17,7 @@
 #include "InsetMathChar.h"
 #include "MathCompletionList.h"
 #include "MathExtern.h"
+#include "MathFactory.h"
 #include "MathStream.h"
 #include "MathSupport.h"
 
@@ -624,6 +625,22 @@ bool MathMacro::idxLast(Cursor & cur) const
 
 bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur)
 {
+       if (displayMode_ == DISPLAY_UNFOLDED) {
+               docstring const & unfolded_name = name();
+               if (unfolded_name != name_) {
+                       // The macro name was changed
+                       cur = old;
+                       bool left = cur.pos() == 0;
+                       cur.recordUndoInset();
+                       cur.popForward();
+                       cur.backspace();
+                       cur.niceInsert(createInsetMath(unfolded_name));
+                       if (left)
+                               cur.backwardPos();
+                       cur.updateFlags(Update::Force);
+                       return true;
+               }
+       }
        cur.updateFlags(Update::Force);
        return InsetMathNest::notifyCursorLeaves(old, cur);
 }