mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Handle failure to select match more gracefully
This commit is contained in:
parent
205d5d432c
commit
0348bf9ad5
@ -138,7 +138,11 @@ def reset_find_caches():
|
||||
|
||||
def select_find_result(match):
|
||||
sel = window.getSelection()
|
||||
sel.setBaseAndExtent(match.start_node, match.start_offset, match.end_node, match.end_offset)
|
||||
try:
|
||||
sel.setBaseAndExtent(match.start_node, match.start_offset, match.end_node, match.end_offset)
|
||||
except: # if offset is outside node
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def select_search_result(sr):
|
||||
@ -158,8 +162,7 @@ def select_search_result(sr):
|
||||
match = find_specific_occurrence(q, int(sr.index), before_len, after_len, cache.text_map, sr.from_offset)
|
||||
if not match:
|
||||
return False
|
||||
select_find_result(match)
|
||||
return True
|
||||
return select_find_result(match)
|
||||
|
||||
|
||||
def select_tts_mark(idx_in_flat_text):
|
||||
@ -175,5 +178,4 @@ def select_tts_mark(idx_in_flat_text):
|
||||
match = get_occurrence_data(cache.text_map.node_list, idx_in_flat_text, idx_in_flat_text + word_length)
|
||||
if not match:
|
||||
return False
|
||||
select_find_result(match)
|
||||
return True
|
||||
return select_find_result(match)
|
||||
|
Loading…
x
Reference in New Issue
Block a user