mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
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:
parent
a911b1cc65
commit
32148586a8
@ -2496,14 +2496,7 @@ void Cursor::recordUndo(UndoKind kind) const
|
||||
|
||||
void Cursor::recordUndoInset(Inset const * in) const
|
||||
{
|
||||
if (!in || in == &inset()) {
|
||||
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.");
|
||||
buffer()->undo().recordUndoInset(*this, in);
|
||||
}
|
||||
|
||||
|
||||
|
13
src/Undo.cpp
13
src/Undo.cpp
@ -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)
|
||||
{
|
||||
d->recordUndoBufferParams(cur);
|
||||
|
@ -102,6 +102,9 @@ public:
|
||||
/// paragraph or cell containing the cursor.
|
||||
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
|
||||
void recordUndoBufferParams(CursorData const & cur);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user