From 464c0a4f1a3f79fb788301095b197840fec066ef Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Dec 2020 15:23:52 +0530 Subject: [PATCH] Handle no mark match better --- src/pyj/read_book/find.pyj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/find.pyj b/src/pyj/read_book/find.pyj index 94527ec47d..328fe00301 100644 --- a/src/pyj/read_book/find.pyj +++ b/src/pyj/read_book/find.pyj @@ -162,7 +162,9 @@ def select_tts_mark(idx_in_flat_text): r = /\w+/g r.lastIndex = idx_in_flat_text match = v'r.exec(cache.text_map.flat_text)' - word_length = match[0]?.length or 5 + word_length = 5 + if match: + word_length = match[0]?.length or 5 match = get_occurrence_data(cache.text_map.node_list, idx_in_flat_text, idx_in_flat_text + word_length) if not match: return False