Better fix for bug #5923. Now the macro name can be freely edited.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30425 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-07-09 15:21:21 +00:00
parent 7d1b297e7e
commit 0c2902d0c0
2 changed files with 17 additions and 13 deletions

View 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;

View 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);
}