From bb58aa60d92b30e24438f6b8e42b45ca4473d768 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 May 2021 13:35:33 +0530 Subject: [PATCH] Handle search result not found --- src/pyj/read_book/search.pyj | 8 ++++++++ src/pyj/read_book/ui.pyj | 1 + 2 files changed, 9 insertions(+) diff --git a/src/pyj/read_book/search.pyj b/src/pyj/read_book/search.pyj index f74c0f41ef..8c9ace6acf 100644 --- a/src/pyj/read_book/search.pyj +++ b/src/pyj/read_book/search.pyj @@ -273,6 +273,14 @@ class SearchOverlay: def search_result_discovered(self, sr): self.make_result_current(sr.result_num) + def search_result_not_found(self, sr): + if sr.on_discovery: + return + error_dialog( + _('Search result not found'), _( + 'This search result matches text that is hidden in the book and cannot be displayed')) + self.show() + def result_clicked(self, rnum): sr = Object.assign({}, self.result_map[rnum]) sr.on_discovery = 0 diff --git a/src/pyj/read_book/ui.pyj b/src/pyj/read_book/ui.pyj index 32954ff755..989652d6a0 100644 --- a/src/pyj/read_book/ui.pyj +++ b/src/pyj/read_book/ui.pyj @@ -88,6 +88,7 @@ class ReadUI: ui_operations.speak_simple_text = self.speak_simple_text.bind(self) ui_operations.tts = self.tts.bind(self) ui_operations.search_result_discovered = self.view.search_overlay.search_result_discovered + ui_operations.search_result_not_found = self.view.search_overlay.search_result_not_found ui_operations.open_url = def(url): window.open(url, '_blank') ui_operations.copy_selection = def(text, html):