diff --git a/src/editor/dtextedit.cpp b/src/editor/dtextedit.cpp index 17c65c4b..b2eb8746 100644 --- a/src/editor/dtextedit.cpp +++ b/src/editor/dtextedit.cpp @@ -1679,7 +1679,7 @@ void TextEdit::updateFont() } } -void TextEdit::replaceAll(const QString &replaceText, const QString &withText) +void TextEdit::replaceAll(const QString &replaceText, const QString &withText, Qt::CaseSensitivity caseFlag) { if (m_readOnlyMode || m_bReadOnlyPermission) { return; @@ -1694,8 +1694,6 @@ void TextEdit::replaceAll(const QString &replaceText, const QString &withText) return; } - QTextDocument::FindFlags flags; - flags &= QTextDocument::FindCaseSensitively; QTextCursor cursor = textCursor(); cursor.movePosition(QTextCursor::Start); QTextCursor startCursor = textCursor(); @@ -1706,10 +1704,10 @@ void TextEdit::replaceAll(const QString &replaceText, const QString &withText) QList backupMarkList = convertMarkToReplace(m_markOperations); auto replaceList = backupMarkList; // 计算替换颜色标记信息 - calcMarkReplaceList(replaceList, oldText, replaceText, withText); + calcMarkReplaceList(replaceList, oldText, replaceText, withText, 0, caseFlag); QString newText = oldText; - newText.replace(replaceText, withText); + newText.replace(replaceText, withText, caseFlag); if (oldText != newText) { ChangeMarkCommand *pChangeMark = new ChangeMarkCommand(this, backupMarkList, replaceList); @@ -1719,7 +1717,7 @@ void TextEdit::replaceAll(const QString &replaceText, const QString &withText) } } -void TextEdit::replaceNext(const QString &replaceText, const QString &withText) +void TextEdit::replaceNext(const QString &replaceText, const QString &withText, Qt::CaseSensitivity caseFlag) { if (m_readOnlyMode || m_bReadOnlyPermission) { return; @@ -1799,7 +1797,7 @@ void TextEdit::replaceNext(const QString &replaceText, const QString &withText) } QString strSelection(cursor.selectedText()); - if (!strSelection.compare(replaceText) || replaceText.contains("\n")) { + if (!strSelection.compare(replaceText, caseFlag) || replaceText.contains("\n")) { ChangeMarkCommand *pChangeMark = new ChangeMarkCommand(this, backupMarkList, replaceList); // 设置插入撤销项为颜色标记变更撤销项的子项 new InsertTextUndoCommand(cursor, withText, this, pChangeMark); @@ -1809,10 +1807,10 @@ void TextEdit::replaceNext(const QString &replaceText, const QString &withText) // Update cursor. setTextCursor(cursor); - highlightKeyword(replaceText, getPosition()); + highlightKeyword(replaceText, getPosition(), caseFlag); } -void TextEdit::replaceRest(const QString &replaceText, const QString &withText) +void TextEdit::replaceRest(const QString &replaceText, const QString &withText, Qt::CaseSensitivity caseFlag) { if (m_readOnlyMode || m_bReadOnlyPermission) { return; @@ -1828,9 +1826,6 @@ void TextEdit::replaceRest(const QString &replaceText, const QString &withText) return; } - QTextDocument::FindFlags flags; - flags &= QTextDocument::FindCaseSensitively; - QTextCursor cursor = textCursor(); QTextCursor startCursor = textCursor(); startCursor.beginEditBlock(); @@ -1844,9 +1839,9 @@ void TextEdit::replaceRest(const QString &replaceText, const QString &withText) QList backupMarkList = convertMarkToReplace(m_markOperations); auto replaceList = backupMarkList; // 计算替换颜色标记信息 - calcMarkReplaceList(replaceList, right, replaceText, withText, pos); + calcMarkReplaceList(replaceList, right, replaceText, withText, pos, caseFlag); - right.replace(replaceText, withText); + right.replace(replaceText, withText, caseFlag); newText += right; if (oldText != newText) { @@ -1860,10 +1855,10 @@ void TextEdit::replaceRest(const QString &replaceText, const QString &withText) setTextCursor(startCursor); } -void TextEdit::beforeReplace(const QString &strReplaceText) +void TextEdit::beforeReplace(const QString &strReplaceText, Qt::CaseSensitivity caseFlag) { if (strReplaceText.isEmpty() || !m_findHighlightSelection.cursor.hasSelection()) { - highlightKeyword(strReplaceText, getPosition()); + highlightKeyword(strReplaceText, getPosition(), caseFlag); } } @@ -1879,8 +1874,9 @@ bool TextEdit::findKeywordForward(const QString &keyword) //setTextCursor(cursor); QTextDocument::FindFlags options; - options &= QTextDocument::FindCaseSensitively; - + if (Qt::CaseSensitive == defaultCaseSensitive) { + options &= QTextDocument::FindCaseSensitively; + } bool foundOne = find(keyword, options); cursor.setPosition(endPos, QTextCursor::MoveAnchor); @@ -1896,8 +1892,9 @@ bool TextEdit::findKeywordForward(const QString &keyword) //setTextCursor(cursor); QTextDocument::FindFlags options; - options &= QTextDocument::FindCaseSensitively; - + if (Qt::CaseSensitive == defaultCaseSensitive) { + options &= QTextDocument::FindCaseSensitively; + } bool foundOne = find(keyword, options); //setTextCursor(recordCursor); @@ -1920,22 +1917,22 @@ void TextEdit::removeKeywords() //setFocus(); } -bool TextEdit::highlightKeyword(QString keyword, int position) +bool TextEdit::highlightKeyword(const QString &keyword, int position, Qt::CaseSensitivity caseFlag) { Q_UNUSED(position) m_findMatchSelections.clear(); updateHighlightLineSelection(); updateCursorKeywordSelection(keyword, true); - bool bRet = updateKeywordSelectionsInView(keyword, m_findMatchFormat, &m_findMatchSelections); + bool bRet = updateKeywordSelectionsInView(keyword, m_findMatchFormat, &m_findMatchSelections, caseFlag); renderAllSelections(); return bRet; } -bool TextEdit::highlightKeywordInView(QString keyword) +bool TextEdit::highlightKeywordInView(const QString &keyword, Qt::CaseSensitivity caseFlag) { m_findMatchSelections.clear(); - bool bRet = updateKeywordSelectionsInView(keyword, m_findMatchFormat, &m_findMatchSelections); + bool bRet = updateKeywordSelectionsInView(keyword, m_findMatchFormat, &m_findMatchSelections, caseFlag); // 直接设置 setExtraSelections 会导致无法显示颜色标记,调用 renderAllSelections 进行显示更新 // setExtraSelections(m_findMatchSelections); renderAllSelections(); @@ -1988,7 +1985,9 @@ bool TextEdit::updateKeywordSelections(QString keyword, QTextCharFormat charForm if (!keyword.isEmpty()) { QTextCursor cursor(document()); QTextDocument::FindFlags flags; - flags |= QTextDocument::FindCaseSensitively; + if (Qt::CaseSensitive == defaultCaseSensitive) { + flags |= QTextDocument::FindCaseSensitively; + } QTextEdit::ExtraSelection extra; extra.format = charFormat; cursor = document()->find(keyword, cursor, flags); @@ -2009,7 +2008,8 @@ bool TextEdit::updateKeywordSelections(QString keyword, QTextCharFormat charForm return false; } -bool TextEdit::updateKeywordSelectionsInView(QString keyword, QTextCharFormat charFormat, QList *listSelection) +bool TextEdit::updateKeywordSelectionsInView(QString keyword, QTextCharFormat charFormat, + QList *listSelection, Qt::CaseSensitivity caseFlag) { // Clear keyword selections first. listSelection->clear(); @@ -2038,7 +2038,9 @@ bool TextEdit::updateKeywordSelectionsInView(QString keyword, QTextCharFormat ch QLatin1Char endLine('\n'); QString multiLineText; QTextDocument::FindFlags flags; - flags |= QTextDocument::FindCaseSensitively; + if (Qt::CaseSensitive == caseFlag) { + flags |= QTextDocument::FindCaseSensitively; + } if (keyword.contains(endLine)) { auto temp = this->textCursor(); temp.setPosition(beginPos); @@ -2048,7 +2050,7 @@ bool TextEdit::updateKeywordSelectionsInView(QString keyword, QTextCharFormat ch multiLineText += endLine; temp.setPosition(temp.position() + 1); } - cursor = findCursor(keyword, multiLineText, 0, false, beginPos); + cursor = findCursor(keyword, multiLineText, 0, false, beginPos, caseFlag); } else { cursor = document()->find(keyword, beginPos, flags); } @@ -2059,14 +2061,16 @@ bool TextEdit::updateKeywordSelectionsInView(QString keyword, QTextCharFormat ch while (!cursor.isNull()) { extra.cursor = cursor; + // 调整为不区分大小写 + Qt::CaseSensitivity option = defaultCaseSensitive; /* 查找字符时,查找到完全相等的时候才高亮,如查找小写f时,大写的F不高亮 */ - if (!extra.cursor.selectedText().compare(keyword) || keyword.contains(endLine)) { + if (!extra.cursor.selectedText().compare(keyword, option) || keyword.contains(endLine, option)) { listSelection->append(extra); } if (keyword.contains(endLine)) { int pos = std::max(extra.cursor.position(), extra.cursor.anchor()); - cursor = findCursor(keyword, multiLineText, pos - beginPos, false, beginPos); + cursor = findCursor(keyword, multiLineText, pos - beginPos, false, beginPos, caseFlag); } else { cursor = document()->find(keyword, cursor, flags); } @@ -2092,10 +2096,15 @@ bool TextEdit::searchKeywordSeletion(QString keyword, QTextCursor cursor, bool f int offsetLines = 3; if (findNext) { - QTextCursor next = document()->find(keyword, cursor, QTextDocument::FindCaseSensitively); + QTextDocument::FindFlags options; + if (Qt::CaseSensitive == defaultCaseSensitive) { + options &= QTextDocument::FindCaseSensitively; + } + + QTextCursor next = document()->find(keyword, cursor, options); if (keyword.contains("\n")) { int pos = std::max(cursor.position(), cursor.anchor()); - next = findCursor(keyword, this->toPlainText(), pos); + next = findCursor(keyword, this->toPlainText(), pos, false, 0, defaultCaseSensitive); } if (!next.isNull()) { m_findHighlightSelection.cursor = next; @@ -2104,10 +2113,15 @@ bool TextEdit::searchKeywordSeletion(QString keyword, QTextCursor cursor, bool f ret = true; } } else { - QTextCursor prev = document()->find(keyword, cursor, QTextDocument::FindBackward | QTextDocument::FindCaseSensitively); + QTextDocument::FindFlags options = QTextDocument::FindBackward; + if (Qt::CaseSensitive == defaultCaseSensitive) { + options &= QTextDocument::FindCaseSensitively; + } + + QTextCursor prev = document()->find(keyword, cursor, options); if (keyword.contains("\n")) { int pos = std::min(cursor.position(), cursor.anchor()); - prev = findCursor(keyword, this->toPlainText().mid(0, pos), -1, true); + prev = findCursor(keyword, this->toPlainText().mid(0, pos), -1, true, defaultCaseSensitive); } if (!prev.isNull()) { m_findHighlightSelection.cursor = prev; @@ -2986,7 +3000,8 @@ void TextEdit::moveText(int from, int to, const QString &text, bool copy) * cursorPos: text起始位置在全文本中的位置 * @return */ -QTextCursor TextEdit::findCursor(const QString &substr, const QString &text, int from, bool backward, int cursorPos) +QTextCursor TextEdit::findCursor(const QString &substr, const QString &text, int from, bool backward, + int cursorPos, Qt::CaseSensitivity caseFlag) { // 处理换行符为 \r\n (光标计算时被视为单个字符)的情况,移除多计算的字符数 // text 均为 \n 结尾 @@ -2997,9 +3012,9 @@ QTextCursor TextEdit::findCursor(const QString &substr, const QString &text, int int index = -1; if (backward) { - index = text.lastIndexOf(findSubStr, from); + index = text.lastIndexOf(findSubStr, from, caseFlag); } else { - index = text.indexOf(findSubStr, from); + index = text.indexOf(findSubStr, from, caseFlag); } if (-1 != index) { auto cursor = this->textCursor(); @@ -5272,7 +5287,8 @@ static void updateMarkReplaceRange(const QList &foundPosList, TextEdit::Mar * @li MarkAll 全文颜色标记 * 1. 替换前后不进行特殊处理 */ -void TextEdit::calcMarkReplaceList(QList &replaceList, const QString &oldText, const QString &replaceText, const QString &withText, int offset) const +void TextEdit::calcMarkReplaceList(QList &replaceList, const QString &oldText, + const QString &replaceText, const QString &withText, int offset, Qt::CaseSensitivity caseFlag) const { // 当前替换项为空或相同,退出 if (replaceList.isEmpty() @@ -5312,7 +5328,7 @@ void TextEdit::calcMarkReplaceList(QList &replaceList QList foundPosList; // 查找替换位置,遍历查找替换文本出现位置 - int findPos = oldText.indexOf(replaceText, findOffset); + int findPos = oldText.indexOf(replaceText, findOffset, caseFlag); // 需要取得左侧所有的变更相对偏移,从文本左侧开始循环遍历 while (-1 != findPos && currentMarkIndex < replaceList.size()) { @@ -5372,7 +5388,7 @@ void TextEdit::calcMarkReplaceList(QList &replaceList // 继续查找替换文本位置 findOffset = findPos + replaceText.size(); - findPos = oldText.indexOf(replaceText, findOffset); + findPos = oldText.indexOf(replaceText, findOffset, caseFlag); } // 继续处理剩余颜色标记偏移 diff --git a/src/editor/dtextedit.h b/src/editor/dtextedit.h index 6fcbf50b..231ab9df 100644 --- a/src/editor/dtextedit.h +++ b/src/editor/dtextedit.h @@ -197,21 +197,22 @@ class TextEdit : public DPlainTextEdit void setFontSize(qreal fontSize); void updateFont(); - void replaceAll(const QString &replaceText, const QString &withText); - void replaceNext(const QString &replaceText, const QString &withText); - void replaceRest(const QString &replaceText, const QString &withText); - void beforeReplace(const QString &strReplaceText); + void replaceAll(const QString &replaceText, const QString &withText, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); + void replaceNext(const QString &replaceText, const QString &withText, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); + void replaceRest(const QString &replaceText, const QString &withText, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); + void beforeReplace(const QString &strReplaceText, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); bool findKeywordForward(const QString &keyword); void removeKeywords(); - bool highlightKeyword(QString keyword, int position); - bool highlightKeywordInView(QString keyword); + bool highlightKeyword(const QString &keyword, int position, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); + bool highlightKeywordInView(const QString &keyword, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); void clearFindMatchSelections(); void updateCursorKeywordSelection(QString keyword, bool findNext); void updateHighlightLineSelection(); bool updateKeywordSelections(QString keyword, QTextCharFormat charFormat, QList &listSelection); - bool updateKeywordSelectionsInView(QString keyword, QTextCharFormat charFormat, QList *listSelection); + bool updateKeywordSelectionsInView(QString keyword, QTextCharFormat charFormat, QList *listSelection, + Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); bool searchKeywordSeletion(QString keyword, QTextCursor cursor, bool findNext); void renderAllSelections(); @@ -549,7 +550,8 @@ public slots: void undo_(); void moveText(int from, int to, const QString& text, bool copy = false); - QTextCursor findCursor(const QString &substr, const QString &text, int from, bool backward = false, int cursorPos = 0); + QTextCursor findCursor(const QString &substr, const QString &text, int from, bool backward = false, int cursorPos = 0, + Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive); void onPressedLineNumber(const QPoint& point); QString selectedText(bool checkCRLF = false); void onEndlineFormatChanged(BottomBar::EndlineFormat from,BottomBar::EndlineFormat to); @@ -603,7 +605,8 @@ public slots: bool isAbleOperation(int iOperationType); // 计算颜色标记替换信息列表 void calcMarkReplaceList(QList &replaceList, const QString &oldText, - const QString &replaceText, const QString &withText, int offset = 0) const; + const QString &replaceText, const QString &withText, int offset = 0, + Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive) const; // 查找行号line起始的折叠区域 bool findFoldBlock(int line, QTextBlock &beginBlock, QTextBlock &endBlock, QTextBlock &curBlock); @@ -861,5 +864,7 @@ private slots: bool m_MidButtonPatse = false; // 鼠标中键黏贴处理 bool m_isPreeditBefore = false; // 上一个输入法时间是否是 preedit int m_preeditLengthBefore = 0; + + Qt::CaseSensitivity defaultCaseSensitive = Qt::CaseInsensitive; // 查找匹配时默认不区分 }; #endif diff --git a/tests/src/editor/ut_textedit.cpp b/tests/src/editor/ut_textedit.cpp index ac357d6c..d329641b 100644 --- a/tests/src/editor/ut_textedit.cpp +++ b/tests/src/editor/ut_textedit.cpp @@ -1801,6 +1801,7 @@ TEST(UT_test_textedit_replaceAll, UT_test_textedit_replaceAll_002) QString strRetAfter(pWindow->currentWrapper()->textEditor()->toPlainText()); ASSERT_TRUE(!strRetAfter.compare(strRetBefore)); + pWindow->deleteLater(); } @@ -1819,6 +1820,35 @@ TEST(UT_test_textedit_replaceAll, UT_test_textedit_replaceAll_003) QString strRetAfter(pWindow->currentWrapper()->textEditor()->toPlainText()); ASSERT_TRUE(!strRetAfter.compare(QString("Holle Holle\nHolle Holle"))); + + pWindow->currentWrapper()->textEditor()->replaceAll(QString("holle"), QString("World")); + strRetAfter = QString(pWindow->currentWrapper()->textEditor()->toPlainText()); + ASSERT_TRUE(!strRetAfter.compare(QString("World World\nWorld World"))); + + pWindow->deleteLater(); +} + +//replaceAll check case sensitive +TEST(UT_test_textedit_replaceAll, UT_test_textedit_replaceAll_CaseSensitive) +{ + Window *pWindow = new Window(); + pWindow->addBlankTab(QString()); + QString strMsg("Hello world\nHello world"); + QTextCursor textCursor = pWindow->currentWrapper()->textEditor()->textCursor(); + pWindow->currentWrapper()->textEditor()->insertTextEx(textCursor, strMsg); + + auto *textEdit = pWindow->currentWrapper()->textEditor(); + + // NotChange + textEdit->replaceAll(QString("hello"), QString("world"), Qt::CaseSensitive); + ASSERT_TRUE(!textEdit->toPlainText().compare(strMsg)); + + textEdit->replaceAll(QString("hello"), QString("World"), Qt::CaseInsensitive); + ASSERT_TRUE(!textEdit->toPlainText().compare(QString("World world\nWorld world"))); + + textEdit->replaceAll(QString("world"), QString("World"), Qt::CaseInsensitive); + ASSERT_TRUE(!textEdit->toPlainText().compare(QString("World World\nWorld World"))); + pWindow->deleteLater(); } @@ -1909,6 +1939,38 @@ TEST(UT_test_textedit_replaceNext, UT_test_textedit_replaceNext_004) pWindow->deleteLater(); } +//replaceNext check sensitive +TEST(UT_test_textedit_replaceNext, UT_test_textedit_replaceNext_CaseSensitive) +{ + Window *pWindow = new Window(); + pWindow->addBlankTab(QString()); + QString strMsg("Hello world\nHello world"); + auto *textEdit = pWindow->currentWrapper()->textEditor(); + QTextCursor textCursor = textEdit->textCursor(); + textEdit->insertTextEx(textCursor, strMsg); + + textCursor = textEdit->textCursor(); + textCursor.movePosition(QTextCursor::Start); + textCursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); + textEdit->setTextCursor(textCursor); + textEdit->m_findHighlightSelection.cursor = textCursor; + + QString strReplaceText("hello"); + QString strWithText("World"); + QString strRetBefore(textEdit->textCursor().block().text()); + + textEdit->replaceNext(strReplaceText, strWithText, Qt::CaseSensitive); + QString strRetAfter(textEdit->textCursor().block().text()); + ASSERT_TRUE(!strRetAfter.compare(strRetBefore)); + + textEdit->setTextCursor(textCursor); + textEdit->m_findHighlightSelection.cursor = textCursor; + textEdit->replaceNext(strReplaceText, strWithText, Qt::CaseInsensitive); + ASSERT_TRUE(!textEdit->toPlainText().compare("World world\nHello world")); + + pWindow->deleteLater(); +} + //replaceRest 001 TEST(UT_test_textedit_replaceRest, UT_test_textedit_replaceRest_001) { @@ -1970,6 +2032,33 @@ TEST(UT_test_textedit_replaceRest, UT_test_textedit_replaceRest_003) pWindow->deleteLater(); } +//replaceRest check case sensitive +TEST(UT_test_textedit_replaceRest, UT_test_textedit_replaceRest_CaseSensitive) +{ + Window *pWindow = new Window(); + pWindow->addBlankTab(QString()); + QString strMsg("Hello world\nHello world Hello world"); + QTextCursor textCursor = pWindow->currentWrapper()->textEditor()->textCursor(); + pWindow->currentWrapper()->textEditor()->insertTextEx(textCursor, strMsg); + + textCursor = pWindow->currentWrapper()->textEditor()->textCursor(); + textCursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor); + pWindow->currentWrapper()->textEditor()->setTextCursor(textCursor); + QString strReplaceText("World"); + QString strWithText("Hello"); + QString strRetBefore(pWindow->currentWrapper()->textEditor()->textCursor().block().text()); + pWindow->currentWrapper()->textEditor()->replaceRest(strReplaceText, strWithText, Qt::CaseSensitive); + QString strRetAfter(pWindow->currentWrapper()->textEditor()->textCursor().block().text()); + ASSERT_TRUE(!strRetAfter.compare(strRetBefore)); + + pWindow->currentWrapper()->textEditor()->replaceRest(strReplaceText, strWithText, Qt::CaseInsensitive); + strRetAfter = QString(pWindow->currentWrapper()->textEditor()->textCursor().block().text()); + ASSERT_TRUE(!strRetAfter.compare("Hello Hello Hello Hello")); + + pWindow->deleteLater(); +} + + //beforeReplace TEST(UT_test_textedit_beforeReplace, UT_test_textedit_beforeReplace_001) { @@ -2050,6 +2139,27 @@ TEST(UT_test_textedit_highlightKeyword, UT_test_textedit_highlightKeyword_001) pWindow->deleteLater(); } +//highlightKeyword case sensitive +TEST(UT_test_textedit_highlightKeyword, UT_test_textedit_highlightKeyword_CaseSensitive) +{ + Window *pWindow = new Window(); + pWindow->addBlankTab(QString()); + QString strMsg("Hello world\nHello world"); + QTextCursor textCursor = pWindow->currentWrapper()->textEditor()->textCursor(); + pWindow->currentWrapper()->textEditor()->insertTextEx(textCursor, strMsg); + + bool bRet = pWindow->currentWrapper()->textEditor()->highlightKeyword(QString("World"), 0); + ASSERT_TRUE(bRet); + + bRet = pWindow->currentWrapper()->textEditor()->highlightKeyword(QString("hello"), 0); + ASSERT_TRUE(bRet); + + bRet = pWindow->currentWrapper()->textEditor()->highlightKeyword(QString("World"), 0, Qt::CaseSensitive); + ASSERT_FALSE(bRet); + + pWindow->deleteLater(); +} + //highlightKeywordInView TEST(UT_test_textedit_highlightKeywordInView, UT_test_textedit_highlightKeywordInView_001) { @@ -2130,8 +2240,12 @@ TEST(UT_test_textedit_updateKeywordSelections, UT_test_textedit_updateKeywordSel QList listExtraSelection; listExtraSelection.append(extraSelection); bool bRet = pWindow->currentWrapper()->textEditor()->updateKeywordSelections(QString("smile"), charFormat, listExtraSelection); + ASSERT_TRUE(bRet == false); + pWindow->currentWrapper()->textEditor()->defaultCaseSensitive = Qt::CaseSensitive; + bRet = pWindow->currentWrapper()->textEditor()->updateKeywordSelections(QString("World"), charFormat, listExtraSelection); ASSERT_TRUE(bRet == false); + pWindow->deleteLater(); } @@ -2151,8 +2265,11 @@ TEST(UT_test_textedit_updateKeywordSelections, UT_test_textedit_updateKeywordSel QList listExtraSelection; listExtraSelection.append(extraSelection); bool bRet = pWindow->currentWrapper()->textEditor()->updateKeywordSelections(QString("world"), charFormat, listExtraSelection); + ASSERT_TRUE(bRet == true); + bRet = pWindow->currentWrapper()->textEditor()->updateKeywordSelections(QString("World"), charFormat, listExtraSelection); ASSERT_TRUE(bRet == true); + pWindow->deleteLater(); }