From 8c502db277ba212860f93d7648d4ef0d233a56a7 Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Wed, 22 Apr 2026 13:31:24 +0800 Subject: [PATCH] fix(editor): hardcode CaseSensitive in replace skip to fix highlight MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove Qt::CaseSensitivity from replaceSkip signal to avoid QueuedConnection enum serialization failure. Hardcode CaseSensitive directly in handleReplaceSkip for correct case-sensitive highlight. 替换跳过信号不再传递caseFlag枚举参数,避免QueuedConnection 序列化丢失。在handleReplaceSkip中直接使用CaseSensitive, 确保跳过后仅高亮精确匹配的内容。 Log: 修复替换跳过后大小写不敏感的高亮问题 PMS: BUG-358129 Influence: 替换跳过后高亮仅匹配相同大小写的内容,不再误匹配不同大小写的文本。 --- src/controls/replacebar.cpp | 2 +- src/controls/replacebar.h | 2 +- src/widgets/window.cpp | 8 ++++---- src/widgets/window.h | 2 +- tests/src/widgets/ut_window.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controls/replacebar.cpp b/src/controls/replacebar.cpp index 6a69955c..6348496e 100644 --- a/src/controls/replacebar.cpp +++ b/src/controls/replacebar.cpp @@ -133,7 +133,7 @@ void ReplaceBar::activeInput(QString text, QString file, int row, int column, in void ReplaceBar::handleSkip() { qDebug() << "handleSkip"; - emit replaceSkip(m_replaceFile, m_replaceLine->lineEdit()->text(), Qt::CaseSensitive); + emit replaceSkip(m_replaceFile, m_replaceLine->lineEdit()->text()); } void ReplaceBar::replaceClose() diff --git a/src/controls/replacebar.h b/src/controls/replacebar.h index cf7f8106..893fe82f 100644 --- a/src/controls/replacebar.h +++ b/src/controls/replacebar.h @@ -36,7 +36,7 @@ class ReplaceBar : public DFloatingWidget Q_SIGNALS: void pressEsc(); void replaceNext(QString file, QString replaceText, QString withText); - void replaceSkip(QString file, QString keyword, Qt::CaseSensitivity caseFlag); + void replaceSkip(QString file, QString keyword); void replaceRest(QString replaceText, QString withText); void replaceAll(QString replaceText, QString withText); void beforeReplace(QString _); diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 71b1f8ad..458f705d 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -3419,17 +3419,17 @@ void Window::handleReplaceRest(const QString &replaceText, const QString &withTe qDebug() << "handleReplaceRest end"; } -void Window::handleReplaceSkip(QString file, QString keyword, Qt::CaseSensitivity caseFlag) +void Window::handleReplaceSkip(QString file, QString keyword) { - qDebug() << "handleReplaceSkip" << file << keyword << caseFlag; + qDebug() << "handleReplaceSkip" << file << keyword; EditWrapper *wrapper = currentWrapper(); - handleUpdateSearchKeyword(m_replaceBar, file, keyword, caseFlag); + handleUpdateSearchKeyword(m_replaceBar, file, keyword, Qt::CaseSensitive); if (QString::compare(m_keywordForSearch, m_keywordForSearchAll, Qt::CaseInsensitive) != 0) { m_keywordForSearchAll.clear(); wrapper->textEditor()->clearFindMatchSelections(); qDebug() << "m_keywordForSearchAll is not equal to m_keywordForSearch, clear it"; } else { - wrapper->textEditor()->highlightKeywordInView(m_keywordForSearchAll, caseFlag); + wrapper->textEditor()->highlightKeywordInView(m_keywordForSearchAll, Qt::CaseSensitive); qDebug() << "m_keywordForSearchAll is equal to m_keywordForSearch, highlight it"; } #if 0 diff --git a/src/widgets/window.h b/src/widgets/window.h index 21e60ae3..b3a36d23 100644 --- a/src/widgets/window.h +++ b/src/widgets/window.h @@ -177,7 +177,7 @@ public Q_SLOTS: void handleReplaceAll(const QString &replaceText, const QString &withText); void handleReplaceNext(const QString &file, const QString &replaceText, const QString &withText); void handleReplaceRest(const QString &replaceText, const QString &withText); - void handleReplaceSkip(QString file, QString keyword, Qt::CaseSensitivity caseFlag); + void handleReplaceSkip(QString file, QString keyword); void handleRemoveSearchKeyword(); void handleUpdateSearchKeyword(QWidget *widget, const QString &file, const QString &keyword, diff --git a/tests/src/widgets/ut_window.cpp b/tests/src/widgets/ut_window.cpp index d04576ba..ec68eaaa 100644 --- a/tests/src/widgets/ut_window.cpp +++ b/tests/src/widgets/ut_window.cpp @@ -1502,7 +1502,7 @@ TEST(UT_Window_handleReplaceSkip, UT_Window_handleReplaceSkip) window->addTabWithWrapper(a,"aa","aad","aadd",0); window->addTabWithWrapper(a,"bb","aad","aadd",1); window->m_settings =Settings::instance(); - window->handleReplaceSkip("aa", "", Qt::CaseSensitive); + window->handleReplaceSkip("aa", ""); EXPECT_NE(window,nullptr); window->deleteLater();