Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [search functionality] Resolve issue with empty editor content #1047

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

Kakueeen
Copy link
Contributor

@Kakueeen Kakueeen commented Jan 7, 2025

This commit addresses a bug where the search functionality would not
work when the editor content was empty. The following changes were made:

  • Changed the channelData type to std::optional<QString> to
    handle cases where there may not be any data to send.

These changes ensure that the search operation can gracefully handle
empty input, improving the overall robustness of the search feature.

Log: Fix search issue when editor content is empty
Bug: https://pms.uniontech.com/bug-view-298499.html

This commit addresses a bug where the search functionality would not
work when the editor content was empty. The following changes were made:

- Changed the `channelData` type to `std::optional<QString>` to
  handle cases where there may not be any data to send.

These changes ensure that the search operation can gracefully handle
empty input, improving the overall robustness of the search feature.

Log: Fix search issue when editor content is empty
Bug: https://pms.uniontech.com/bug-view-298499.html
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. AdvancedSearchWidgetPrivate类的构造函数中,d指针的初始化使用了C++11的列表初始化语法,这是一个好的实践,但应确保编译器支持C++11或更高版本。

  2. registerOperator函数中,btn->setToolTip(description);之后添加了一个空行,这是一个好的习惯,可以提高代码的可读性。

  3. handleReplaceAll函数中,isReplaceAll被设置为true,这是一个合理的做法,但应确保在所有可能的情况下都正确地重置该标志,以避免潜在的逻辑错误。

  4. handleReplaceFinished函数中,isReplaceAll被重置为false,这是一个好的做法,可以避免在后续操作中误用该标志。

  5. handleReplaceFinished函数中,使用了std::accumulate来计算替换结果的数量,这是一个好的做法,可以提高代码的效率和可读性。

  6. SearchReplaceWorkerPrivate类的startNextJob函数中,job.channelData.isEmpty()被替换为job.channelData.has_value(),这是一个好的做法,因为std::optional提供了更清晰的语义。

  7. SearchReplaceWorkerPrivate类的私有数据成员中,channelData的类型从QString更改为std::optional<QString>,这是一个好的做法,因为std::optional可以更清晰地表示该成员可能为空。

  8. SearchReplaceWorkerPrivate类的头文件中,SearchReplaceWorkerPrivate类的定义中,channelData的类型从QString更改为std::optional<QString>,这是一个好的做法,因为std::optional可以更清晰地表示该成员可能为空。

总体来说,代码的修改提高了代码的可读性和可维护性,同时也修复了一些潜在的问题。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kakueeen, LiHua000
Once this PR has been reviewed and has the lgtm label, please assign deepin-mozart for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-mozart deepin-mozart merged commit d7c500d into linuxdeepin:master Jan 7, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants