fix: Skip case insensitive#448
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Apr 23, 2026
Merged
Conversation
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 418,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 391,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 390,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
log: m_searchCaseFlag was not persisted. After a replace bar operation, any cursor movement or scrolling would re-highlight using the default CaseInsensitive, overwriting the correct case-sensitive setting. Added m_searchCaseFlag to store the current search case flag, set replace bar related operations to CaseSensitive uniformly, and changed all highlightKeywordInView calls to read this flag. pms: bug-358129
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 390,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
deepin pr auto reviewGit Diff 代码审查报告总体评价这段代码主要实现了文本编辑器中搜索高亮功能的大小写敏感性支持。代码修改了多个函数,增加了对大小写敏感标志的传递和使用。整体修改逻辑清晰,但存在一些可以改进的地方。 详细审查意见1. 语法与逻辑问题
2. 代码质量问题
3. 性能问题
4. 安全性问题
改进建议代码1. 提取重复代码// 在 TextEdit 类中添加新方法
void TextEdit::updateHighlighterIfNeeded()
{
if (m_wrapper == nullptr) {
return;
}
qDebug() << "Updating highlighter";
m_wrapper->OnUpdateHighlighter();
Window *win = m_wrapper->window();
if (!win) {
return;
}
const QString keyword = win->getKeywordForSearchAll();
if ((win->findBarIsVisible() || win->replaceBarIsVisible()) &&
(QString::compare(keyword, win->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
qDebug() << "Highlighting keyword in view";
highlightKeywordInView(keyword, win->getSearchCaseFlag());
}
qDebug() << "Marking all keyword in view";
markAllKeywordInView();
}
// 然后修改原函数
void TextEdit::nextLine()
{
// ... 原有代码 ...
updateHighlighterIfNeeded();
// ... 原有代码 ...
}2. 修复拼写错误并添加空指针检查// 在 Window 类中修改方法名
bool Window::findBarIsVisible()
{
// ...
}
bool Window::replaceBarIsVisible()
{
// ...
}
// 在 TextEdit 类中使用
void TextEdit::nextLine()
{
// ...
if (m_wrapper != nullptr) {
Window *win = m_wrapper->window();
if (!win) {
return;
}
// ...
}
// ...
}3. 使用默认参数值// 在 TextEdit 类中修改方法声明
void highlightKeywordInView(const QString &keyword, Qt::CaseSensitivity caseFlag = Qt::CaseInsensitive);4. 统一初始化大小写敏感标志// 在 Window 类构造函数中
Window::Window(DMainWindow *parent) : DMainWindow(parent)
{
// ...
m_searchCaseFlag = Qt::CaseInsensitive; // 统一初始化默认值
// ...
}总结这段代码修改主要实现了搜索高亮功能的大小写敏感性支持,整体逻辑正确,但存在一些可以改进的地方:
通过这些改进,可以提高代码的可读性、可维护性和健壮性。 |
lzwind
approved these changes
Apr 22, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JWWTSL, lzwind 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 |
Contributor
Author
|
/forcemerge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
log: m_searchCaseFlag was not persisted. After a replace bar operation, any cursor movement or scrolling would re-highlight using the default CaseInsensitive, overwriting the correct case-sensitive setting. Added m_searchCaseFlag to store the current search case flag, set replace bar related operations to CaseSensitive uniformly, and changed all highlightKeywordInView calls to read this flag.
pms: bug-358129