From 06d4b62b673a562701074f4576cd03591818c646 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:33:49 +0800 Subject: [PATCH] opt: findtext casesensitivity (#1698) * opt: reset the selection results * opt: remove the existed highlight when no match * [autofix.ci] apply automated fixes * opt: remove the existed highlight when no match * opt: remove the existed highlight when no match * opt: code minor optimization --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/ui/articleview.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index 048fcc5a..3c6d306a 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -2026,8 +2026,13 @@ void ArticleView::performFindOperation( bool backwards ) f |= QWebEnginePage::FindBackward; findText( text, f, [ text, this ]( bool match ) { - bool setMark = !text.isEmpty() && !match; - Utils::Widget::setNoResultColor( searchPanel->lineEdit, setMark ); + bool nomatch = !text.isEmpty() && !match; + if ( nomatch ) { + //clear the previous findText results. + //when the results is empty, the highlight has not been removed.more likely a qt bug. + webview->findText( "" ); + } + Utils::Widget::setNoResultColor( searchPanel->lineEdit, nomatch ); } ); } @@ -2065,10 +2070,7 @@ bool ArticleView::closeSearch() ftsSearchPanel->hide(); webview->setFocus(); - QWebEnginePage::FindFlags flags( 0 ); - - webview->findText( "", flags ); - + webview->findText( "" ); return true; } return false;