Commit e82a45cb authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 442416 - Text highlight while composing or replaying the message

BUG: 442416
FIXED-IN: 21.08.2
parent 64559333
Pipeline #80546 passed with stage
in 5 minutes and 15 seconds
......@@ -928,3 +928,51 @@ void TextHTMLBuilderTest::testBug436880()
delete hb;
delete doc;
}
void TextHTMLBuilderTest::testBug442416()
{
auto doc = new QTextDocument();
doc->setHtml(QStringLiteral(
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;\"><span "
"style=\" background-color:#ffff00;\">Sss</span></p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; "
"-qt-block-indent:0; text-indent:0px; -qt-user-state:0;\"><span style=\" background-color:#ffff00;\">sss</span></p>"));
auto hb = new KPIMTextEdit::TextHTMLBuilder();
auto md = new KPIMTextEdit::MarkupDirector(hb);
md->processDocument(doc);
auto result = hb->getResult();
// qDebug() << " result " << result;
auto regex = QRegularExpression(
QStringLiteral("^<p style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"background-color:#ffff00;\">Sss</span></p>\n<p "
"style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"background-color:#ffff00;\">sss</span></p>\n"));
QVERIFY(regex.match(result).hasMatch());
delete md;
delete hb;
delete doc;
}
void TextHTMLBuilderTest::testBug442416Bis()
{
auto doc = new QTextDocument();
doc->setHtml(QStringLiteral(
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;\"><span "
"style=\" background-color:#ffff00;\">Sss</span></p>\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; "
"-qt-block-indent:0; text-indent:0px; -qt-user-state:0;\"><span style=\" background-color:#ff0000;\">sss</span></p>"));
auto hb = new KPIMTextEdit::TextHTMLBuilder();
auto md = new KPIMTextEdit::MarkupDirector(hb);
md->processDocument(doc);
auto result = hb->getResult();
// qDebug() << " result " << result;
auto regex = QRegularExpression(
QStringLiteral("^<p style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"background-color:#ffff00;\">Sss</span></p>\n<p "
"style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"background-color:#ff0000;\">sss</span></p>\n"));
QVERIFY(regex.match(result).hasMatch());
delete md;
delete hb;
delete doc;
}
......@@ -48,6 +48,8 @@ private Q_SLOTS:
void testBug421908_2();
void testBug421908_full();
void testBug436880();
void testBug442416();
void testBug442416Bis();
};
#endif // TEXTHTMLBUILDERTEST_H
......@@ -528,6 +528,8 @@ void MarkupDirector::processClosingElements(const QTextBlock::iterator &it)
break;
case SpanBackground:
m_builder->endBackground();
// Clear background otherwise if we select 2 lines with same color it will not applied. bug #442416
d->m_openBackground = {};
break;
case SpanForeground:
m_builder->endForeground();
......
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