Simpler fix for undo support when entering \hline in an equation

* Avoid undo step when using backspace in macro mode
 * Use recordUndoInset when entering macro mode (if one enters something like \hline, the outer inset itself will be modified)
 * Use recordUndoInset when pasting in an INsetMathGrid (same reason as above)
This commit is contained in:
Jean-Marc Lasgouttes 2012-04-17 10:55:59 +02:00
parent 201dcc8ec3
commit 9059843121
2 changed files with 3 additions and 2 deletions

View File

@ -1356,7 +1356,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
hline_enabled = status.enabled();
if (grid.nargs() == 1) {
// single cell/part of cell
cur.recordUndo();
cur.recordUndoInset();
cur.cell().insert(cur.pos(), grid.cell(0));
cur.pos() += grid.cell(0).size();
if (hline_enabled)

View File

@ -806,7 +806,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
if (cur.pos() == 0)
// May affect external cell:
cur.recordUndoInset();
else
else if (!cur.inMacroMode())
cur.recordUndoSelection();
// if the inset can not be removed from within, delete it
if (!cur.backspace()) {
@ -1705,6 +1705,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
//lyxerr << "starting with macro" << endl;
bool reduced = cap::reduceSelectionToOneCell(cur);
if (reduced || !cur.selection()) {
cur.recordUndoInset();
docstring const safe = cap::grabAndEraseSelection(cur);
if (!cur.inRegexped())
cur.insert(MathAtom(new InsetMathUnknown(from_ascii("\\"), safe, false)));