diff --git a/src/calibre/gui2/viewer/search.py b/src/calibre/gui2/viewer/search.py index c819dea109..6ea11cdd41 100644 --- a/src/calibre/gui2/viewer/search.py +++ b/src/calibre/gui2/viewer/search.py @@ -313,14 +313,14 @@ def toc_nodes_for_search_result(sr): def search_in_name(name, search_query, ctx_size=75): raw = searchable_text_for_name(name)[0] - if search_query.mode in ('word', 'regex') or search_query.case_sensitive: + if search_query.mode == 'regex' or search_query.case_sensitive: def miter(): for match in search_query.regex.finditer(raw): yield match.span() else: spans = [] a = lambda s, l: spans.append((s, s + l)) - primary_collator_without_punctuation().find_all(search_query.text, raw, a) + primary_collator_without_punctuation().find_all(search_query.text, raw, a, search_query.mode == 'word') miter = lambda: spans for (start, end) in miter(): @@ -380,7 +380,8 @@ class SearchInput(QWidget): # {{{ 'Choose the type of search: