From 2b5b161379a2a36ca0df712de87aedd267114c76 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 17 Oct 2023 09:02:56 +0530 Subject: [PATCH] E-book viewer: Fix a regression that could cause the viewer to enter an infinite loop when displaying the result of a search that has only one match that is not found. Fixes #2038747 [Private bug](https://bugs.launchpad.net/calibre/+bug/2038747) --- src/pyj/read_book/view.pyj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 869ab61802..cf471888a7 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -1420,7 +1420,7 @@ class View: if sr.result_num is 1: self.search_result_discovery = { 'queue': v'[]', 'on_discovery': sr.on_discovery, 'in_flight': None, 'discovered': False, - 'first_search_result': sr, 'finished': False, + 'first_search_result': sr, 'finished': False, 'jump_forced': False, } if not self.search_result_discovery or self.search_result_discovery.discovered or self.search_result_discovery.on_discovery is not sr.on_discovery: return @@ -1437,9 +1437,10 @@ class View: ui_operations.search_result_discovered(sr) elif not self.search_result_discovery.discovered and self.search_result_discovery.queue.length: self.show_search_result(self.search_result_discovery.queue.shift()) - elif not self.search_result_discovery.discovered and self.search_result_discovery.finished: + elif not self.search_result_discovery.discovered and self.search_result_discovery.finished and not self.search_result_discovery.jump_forced: sr = self.search_result_discovery.first_search_result sr.force_jump_to = True + self.search_result_discovery.jump_forced = True self.show_search_result(sr) def search_result_discovered(self, data):