diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-03 13:00:45 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-02-08 16:24:09 +0100 |
commit | a66b48a06bc60c3b9591f5f9170c60d22ca67dcf (patch) | |
tree | a29b12c0c133b89f95ccac5c6d900626abb4830d | |
parent | 3f4db416150e06afca2d3010a9ea4ea61e74b8b6 (diff) |
Update searches faster
Cancel previous search if not yet finished.
Change-Id: Ie17b2b773bc9d23970c8178ef8be47c19cd768a3
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r-- | src/core/find_text_helper.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/find_text_helper.cpp b/src/core/find_text_helper.cpp index c3b407ab1..534e25862 100644 --- a/src/core/find_text_helper.cpp +++ b/src/core/find_text_helper.cpp @@ -97,18 +97,18 @@ void FindTextHelper::startFinding(const QString &findText, bool caseSensitively, void FindTextHelper::startFinding(const QString &findText, bool caseSensitively, bool findBackward) { - if (findText.isEmpty()) { - stopFinding(); - return; - } + Q_ASSERT(!findText.isEmpty()); - if (m_currentFindRequestId > m_lastCompletedFindRequestId) { + const bool findNext = !m_previousFindText.isEmpty() && findText == m_previousFindText; + if (isFindTextInProgress()) { // There are cases where the render process will overwrite a previous request // with the new search and we'll have a dangling callback, leaving the application // waiting for it forever. // Assume that any unfinished find has been unsuccessful when a new one is started // to cover that case. m_lastCompletedFindRequestId = m_currentFindRequestId; + if (!findNext) + m_webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION); m_viewClient->findTextFinished(QWebEngineFindTextResult()); invokeResultCallback(m_currentFindRequestId, 0); } @@ -116,7 +116,7 @@ void FindTextHelper::startFinding(const QString &findText, bool caseSensitively, blink::mojom::FindOptionsPtr options = blink::mojom::FindOptions::New(); options->forward = !findBackward; options->match_case = caseSensitively; - options->new_session = findText != m_previousFindText; + options->new_session = !findNext; m_previousFindText = findText; m_currentFindRequestId = m_findRequestIdCounter++; |