diff --git a/autotests/krichtextedittest.h b/autotests/krichtextedittest.h --- a/autotests/krichtextedittest.h +++ b/autotests/krichtextedittest.h @@ -34,6 +34,7 @@ void testHTMLOrderedLists(); void testHTMLUnorderedLists(); void testHeading(); + void testRulerScroll(); }; #endif diff --git a/autotests/krichtextedittest.cpp b/autotests/krichtextedittest.cpp --- a/autotests/krichtextedittest.cpp +++ b/autotests/krichtextedittest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include QTEST_MAIN(KRichTextEditTest) @@ -311,3 +312,21 @@ QCOMPARE(edit.textCursor().blockFormat().headingLevel(), 5); QCOMPARE(edit.fontWeight(), static_cast(QFont::Bold)); } + +void KRichTextEditTest::testRulerScroll() +{ + // This is a test for bug 195828 + KRichTextEdit edit; + // Add some lines, so that scroll definitely appears + for (int i = 0; i < 100; i++) { + QTest::keyClicks(&edit, QStringLiteral("New line\r")); + } + // Widget has to be shown for the scrollbar to be adjusted + edit.show(); + // Ensure the scrollbar actually appears + QVERIFY(edit.verticalScrollBar()->value() > 0); + + edit.insertHorizontalRule(); + // Make sure scrollbar didn't jump to the top + QVERIFY(edit.verticalScrollBar()->value() > 0); +} diff --git a/src/widgets/krichtextedit.cpp b/src/widgets/krichtextedit.cpp --- a/src/widgets/krichtextedit.cpp +++ b/src/widgets/krichtextedit.cpp @@ -168,9 +168,9 @@ cursor.beginEditBlock(); cursor.insertHtml(QStringLiteral("
")); cursor.insertBlock(bf, cf); + cursor.endEditBlock(); setTextCursor(cursor); d->activateRichText(); - cursor.endEditBlock(); } void KRichTextEdit::alignLeft()