From ac12d5933aa982945c5bd723426bc0b1c3972c0e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Mar 2020 11:40:00 +0530 Subject: [PATCH] Viewer search: Fix jumping to next match sometimes selecting previous match if the searched for expression occurs with identical context in multiple places. Fixes #1868633 [Private bug](https://bugs.launchpad.net/calibre/+bug/1868633) --- src/pyj/read_book/find.pyj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyj/read_book/find.pyj b/src/pyj/read_book/find.pyj index 03ea74f69d..fa000f9ad5 100644 --- a/src/pyj/read_book/find.pyj +++ b/src/pyj/read_book/find.pyj @@ -79,7 +79,7 @@ def find_specific_occurrence(q, num, before_len, after_len, text_map): break match_num += 1 from_idx = idx + 1 - if num < match_num: + if match_num < num: continue start_node, start_offset, node_pos = find_node_for_index_binary(text_map.node_list, idx + before_len, pos) if start_node is not None: