|| 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;
#include "InsetMathChar.h"
#include "MathCompletionList.h"
#include "MathExtern.h"
+#include "MathFactory.h"
#include "MathStream.h"
#include "MathSupport.h"
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);
}