diff --git a/autotests/chattextitemhelpertest.qml b/autotests/chattextitemhelpertest.qml index 8ec9acfda..512f1b61b 100644 --- a/autotests/chattextitemhelpertest.qml +++ b/autotests/chattextitemhelpertest.qml @@ -109,6 +109,34 @@ TestCase { compare(spyCursor.count, 5); } + function test_longFixedChars(): void { + textEdit.forceActiveFocus(); + testHelper.setFixedChars("111", "222"); + compare(textEdit.text, "111222"); + compare(textEdit.cursorPosition, 3); + compare(spyCursor.count, 0); + keyClick("b"); + compare(textEdit.text, "111b222"); + compare(textEdit.cursorPosition, 4); + compare(spyCursor.count, 1); + keyClick(Qt.Key_Left); + compare(textEdit.text, "111b222"); + compare(textEdit.cursorPosition, 3); + compare(spyCursor.count, 2); + keyClick(Qt.Key_Left); + compare(textEdit.text, "111b222"); + compare(textEdit.cursorPosition, 3); + compare(spyCursor.count, 3); + keyClick(Qt.Key_Right); + compare(textEdit.text, "111b222"); + compare(textEdit.cursorPosition, 4); + compare(spyCursor.count, 4); + keyClick(Qt.Key_Right); + compare(textEdit.text, "111b222"); + compare(textEdit.cursorPosition, 4); + compare(spyCursor.count, 5); + } + function test_document(): void { // We can't get to the QTextDocument from QML so we have to use a helper function. compare(testHelper.compareDocuments(textEdit.textDocument), true); diff --git a/autotests/texthandlertest.cpp b/autotests/texthandlertest.cpp index 6a472f0ed..e798d4e47 100644 --- a/autotests/texthandlertest.cpp +++ b/autotests/texthandlertest.cpp @@ -626,10 +626,10 @@ void TextHandlerTest::componentOutput_data() MessageComponent{MessageComponentType::Code, u"Some code"_s, QVariantMap{{u"class"_s, u"html"_s}}}}; QTest::newRow("quote") << u"

Text

\n
\n

blockquote

\n
"_s << QList{MessageComponent{MessageComponentType::Text, u"Text"_s, {}}, - MessageComponent{MessageComponentType::Quote, u"“blockquote”"_s, {}}}; + MessageComponent{MessageComponentType::Quote, u"\"blockquote\""_s, {}}}; QTest::newRow("multiple paragraph quote") << u"
\n

blockquote

\n

next paragraph

\n
"_s << QList{ - MessageComponent{MessageComponentType::Quote, u"

“blockquote

\n

next paragraph”

"_s, {}}}; + MessageComponent{MessageComponentType::Quote, u"

\"blockquote

\n

next paragraph\"

"_s, {}}}; QTest::newRow("no tag first paragraph") << u"Text\n

Text

"_s << QList{MessageComponent{MessageComponentType::Text, u"Text"_s, {}}, MessageComponent{MessageComponentType::Text, u"Text"_s, {}}}; diff --git a/src/libneochat/chattextitemhelper.cpp b/src/libneochat/chattextitemhelper.cpp index 09646c817..efeab6f1c 100644 --- a/src/libneochat/chattextitemhelper.cpp +++ b/src/libneochat/chattextitemhelper.cpp @@ -186,7 +186,7 @@ void ChatTextItemHelper::initialize() cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, m_fixedEndChars.length()); if (cursor.selectedText() != m_fixedEndChars) { - cursor.keepPositionOnInsert(); + cursor.movePosition(QTextCursor::End); cursor.insertText(m_fixedEndChars); } }