From f2c64515699ba6a85fd61f9e787693e1ff1e1927 Mon Sep 17 00:00:00 2001 From: Fernando Bunn Date: Fri, 11 Aug 2023 15:47:26 +0100 Subject: [PATCH] Fix search selection --- .../FindInPageTabExtension.swift | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/DuckDuckGo/Tab/TabExtensions/FindInPageTabExtension.swift b/DuckDuckGo/Tab/TabExtensions/FindInPageTabExtension.swift index 2ae5845b6d..0fea32ea90 100644 --- a/DuckDuckGo/Tab/TabExtensions/FindInPageTabExtension.swift +++ b/DuckDuckGo/Tab/TabExtensions/FindInPageTabExtension.swift @@ -56,24 +56,17 @@ final class FindInPageTabExtension: TabExtension { @MainActor private func showFindInPage() async { - guard !model.isVisible else { - // Find In Page is already active - guard !model.text.isEmpty, - // would just find next for PDF - !isPdf else { return } - - // re-highlight the same result when Find In Page is already active - await find(model.text, with: [.noIndexChange, .determineMatchIndex, .showOverlay]) - return - } - model.show() - await reset() - guard !model.text.isEmpty else { return } + if !model.text.isEmpty { + await find(model.text, with: [.noIndexChange, .determineMatchIndex, .showOverlay]) + } else { + await reset() + guard !model.text.isEmpty else { return } - await find(model.text, with: .showOverlay) - await doItOneMoreTimeForPdf(with: model.text) + await find(model.text, with: .showOverlay) + await doItOneMoreTimeForPdf(with: model.text) + } } /// clear Find In Page state