fix(editor): hardcode CaseSensitive in replace skip to fix highlight#447
Conversation
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: 替换跳过后高亮仅匹配相同大小写的内容,不再误匹配不同大小写的文本。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideHardens the replace-skip workflow by removing the CaseSensitivity enum from the replaceSkip signal/slot interface and instead always using Qt::CaseSensitive inside Window::handleReplaceSkip, preventing QueuedConnection enum serialization issues and ensuring case-sensitive highlighting after skipping replacements. Sequence diagram for updated replaceSkip interactionsequenceDiagram
actor User
participant ReplaceBar
participant Window
participant EditWrapper
participant TextEditor
User->>ReplaceBar: clickSkip()
ReplaceBar->>Window: replaceSkip(file, keyword)
Window->>Window: handleReplaceSkip(file, keyword)
Window->>Window: handleUpdateSearchKeyword(m_replaceBar, file, keyword, Qt::CaseSensitive)
Window->>EditWrapper: currentWrapper()
EditWrapper-->>Window: wrapper
alt m_keywordForSearchAll not equal m_keywordForSearch (caseInsensitive)
Window->>TextEditor: clearFindMatchSelections()
else equal
Window->>TextEditor: highlightKeywordInView(m_keywordForSearchAll, Qt::CaseSensitive)
end
Updated class diagram for ReplaceBar and Window replaceSkip handlingclassDiagram
class ReplaceBar {
+void activeInput(QString text, QString file, int row, int column, int length)
+void handleSkip()
+void replaceClose()
<<signal>> void pressEsc()
<<signal>> void replaceNext(QString file, QString replaceText, QString withText)
<<signal>> void replaceSkip(QString file, QString keyword)
<<signal>> void replaceRest(QString replaceText, QString withText)
<<signal>> void replaceAll(QString replaceText, QString withText)
<<signal>> void beforeReplace(QString _)
}
class Window {
+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)
+void handleRemoveSearchKeyword()
+void handleUpdateSearchKeyword(QWidget widget, const QString file, const QString keyword, Qt::CaseSensitivity caseSensitivity)
QString m_keywordForSearch
QString m_keywordForSearchAll
EditWrapper* currentWrapper()
}
class EditWrapper {
+TextEditor* textEditor()
}
class TextEditor {
+void clearFindMatchSelections()
+void highlightKeywordInView(const QString keyword, Qt::CaseSensitivity caseSensitivity)
}
ReplaceBar ..> Window : signal replaceSkip
Window ..> EditWrapper : uses
EditWrapper ..> TextEditor : uses
Window ..> TextEditor : calls highlighting methods
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码修改主要是移除了 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进建议
总结这段代码修改虽然语法正确,但牺牲了功能的灵活性和一致性。建议恢复 |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider adding a brief code comment near
replaceSkip/handleReplaceSkipexplaining why the case sensitivity is now hardcoded (QueuedConnection enum serialization issue), so future refactors don’t inadvertently reintroduce the enum parameter. - Since
Qt::CaseSensitiveis now the fixed behavior, you could centralize this choice (e.g., a local constexpr or helper) instead of repeating the literal in multiple calls, which will make future behavior changes easier.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding a brief code comment near `replaceSkip` / `handleReplaceSkip` explaining why the case sensitivity is now hardcoded (QueuedConnection enum serialization issue), so future refactors don’t inadvertently reintroduce the enum parameter.
- Since `Qt::CaseSensitive` is now the fixed behavior, you could centralize this choice (e.g., a local constexpr or helper) instead of repeating the literal in multiple calls, which will make future behavior changes easier.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 389,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
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: 替换跳过后高亮仅匹配相同大小写的内容,不再误匹配不同大小写的文本。
Summary by Sourcery
Ensure replace-skip operations always use case-sensitive matching and highlighting by simplifying the replaceSkip signal/slot interface.
Bug Fixes:
Tests: