Place the cursor correctly after undoing an inset dissolution

The cleanup in 11ca1406 was not correct. It is actually not possible to implement recordUndoInset from the undo API, since the cursor may not be at a different level than the text to be saved.

Fixes ticket #9553
This commit is contained in:
Jean-Marc Lasgouttes 2015-05-20 12:09:12 +02:00
parent a911b1cc65
commit 32148586a8
3 changed files with 17 additions and 8 deletions

View File

@ -2496,14 +2496,7 @@ void Cursor::recordUndo(UndoKind kind) const
void Cursor::recordUndoInset(Inset const * in) const void Cursor::recordUndoInset(Inset const * in) const
{ {
if (!in || in == &inset()) { buffer()->undo().recordUndoInset(*this, in);
CursorData c = *this;
c.pop_back();
buffer()->undo().recordUndo(c, c.pit(), c.pit());
} else if (in == nextInset())
recordUndo();
else
LYXERR0("Inset not found, no undo element added.");
} }

View File

@ -587,6 +587,19 @@ void Undo::recordUndo(CursorData const & cur, pit_type from, pit_type to)
} }
void Undo::recordUndoInset(CursorData const & cur, Inset const * inset)
{
if (!inset || inset == &cur.inset()) {
DocIterator c = cur;
c.pop_back();
d->recordUndo(ATOMIC_UNDO, c, c.pit(), c.pit(), cur);
} else if (inset == cur.nextInset())
recordUndo(cur);
else
LYXERR0("Inset not found, no undo stack added.");
}
void Undo::recordUndoBufferParams(CursorData const & cur) void Undo::recordUndoBufferParams(CursorData const & cur)
{ {
d->recordUndoBufferParams(cur); d->recordUndoBufferParams(cur);

View File

@ -102,6 +102,9 @@ public:
/// paragraph or cell containing the cursor. /// paragraph or cell containing the cursor.
void recordUndo(CursorData const & cur, UndoKind kind = ATOMIC_UNDO); void recordUndo(CursorData const & cur, UndoKind kind = ATOMIC_UNDO);
/// prepare undo for the inset containing the cursor
void recordUndoInset(CursorData const & cur, Inset const * inset);
/// Convenience: record undo for buffer parameters /// Convenience: record undo for buffer parameters
void recordUndoBufferParams(CursorData const & cur); void recordUndoBufferParams(CursorData const & cur);