Skip to content

Commit

Permalink
Fix search selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Aug 11, 2023
1 parent 0295515 commit f2c6451
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions DuckDuckGo/Tab/TabExtensions/FindInPageTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2c6451

Please sign in to comment.