From kde-commits Wed Feb 13 17:53:02 2013 From: Pierre Stirnweiss Date: Wed, 13 Feb 2013 17:53:02 +0000 To: kde-commits Subject: [calligra] libs/kotext: Fix merge style to caret without selection Message-Id: <20130213175302.C48E3A6091 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=136077799328011 Git commit e7de1becab5b0a7648ae960f48c0df538f9bc1bd by Pierre Stirnweiss. Committed on 13/01/2013 at 10:42. Pushed by pstirnweiss into branch 'master'. Fix merge style to caret without selection The style was not properly merged to the caret if there was no selected text. REVIEW: 108379 M +10 -0 libs/kotext/KoTextEditor_format.cpp http://commits.kde.org/calligra/e7de1becab5b0a7648ae960f48c0df538f9bc1bd diff --git a/libs/kotext/KoTextEditor_format.cpp b/libs/kotext/KoTextEditor= _format.cpp index d9e81a1..c729653 100644 --- a/libs/kotext/KoTextEditor_format.cpp +++ b/libs/kotext/KoTextEditor_format.cpp @@ -564,10 +564,20 @@ void KoTextEditor::mergeAutoStyle(const QTextCharForm= at &deltaCharFormat) { d->updateState(KoTextEditor::Private::Custom, "Formatting"); = + int caretAnchor =3D d->caret.anchor(); + int caretPosition =3D d->caret.position(); MergeAutoCharacterStyleVisitor visitor(this, deltaCharFormat); = recursivelyVisitSelection(d->document->rootFrame()->begin(), visitor); = + if (!isEditProtected() && caretAnchor =3D=3D caretPosition) { //if the= re is no selection, it can happen that the caret does not get the proper st= yle applied (begining of a block). We need to force it. + d->caret.mergeCharFormat(deltaCharFormat); + } + else { + d->caret.setPosition(caretAnchor); + d->caret.setPosition(caretPosition, QTextCursor::KeepAnchor); + } + d->updateState(KoTextEditor::Private::NoOp); emit textFormatChanged(); }