Commit bb018a76 authored by C. Boemann's avatar C. Boemann

Fix undo redo of textranges - we might have swapped anchor and pos

in general that would not be that big a deal if not for a qt bug which makes the anchor travel even if
the qtextcursor has keepPositionOnInsert() == true

There was another part to this bug - we didn't make sure the text was relayouted

so in short: the anchor was lost (misplaced) and the relayout was never initiated

BUG: 342869
parent af46a26f
......@@ -43,8 +43,8 @@ public:
QTextCursor cursor;
KoTextInlineRdf *rdf; //< A textrange might have RDF, we own it.
bool positionOnlyMode;
int snapStart;
int snapEnd;
int snapAnchor;
int snapPos;
};
KoTextRange::KoTextRange(const QTextCursor &cursor)
......@@ -159,13 +159,13 @@ KoTextInlineRdf* KoTextRange::inlineRdf() const
void KoTextRange::snapshot()
{
Q_D(KoTextRange);
d->snapStart = d->cursor.selectionStart();
d->snapEnd = d->cursor.selectionEnd();
d->snapAnchor = d->cursor.anchor();
d->snapPos = d->cursor.position();
}
void KoTextRange::restore()
{
Q_D(KoTextRange);
d->cursor.setPosition(d->snapStart);
d->cursor.setPosition(d->snapEnd, QTextCursor::KeepAnchor);
d->cursor.setPosition(d->snapAnchor);
d->cursor.setPosition(d->snapPos, QTextCursor::KeepAnchor);
}
......@@ -81,6 +81,7 @@ void DeleteAnchorsCommand::redo()
if (rangeManager) {
foreach (KoAnchorTextRange *anchorRange, m_anchorRanges) {
rangeManager->remove(anchorRange);
m_document->markContentsDirty(anchorRange->position(), 0);
}
}
}
......@@ -99,6 +100,7 @@ void DeleteAnchorsCommand::undo()
if (rangeManager) {
foreach (KoAnchorTextRange *anchorRange, m_anchorRanges) {
rangeManager->insert(anchorRange);
m_document->markContentsDirty(anchorRange->position(), 0);
}
}
m_deleteAnchors = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment