mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Viewer: Fix searching in flow mode not scrolling to display the search results. Fixes #1866519 [ebook-viewer 4.12 searching doesn't jump to results](https://bugs.launchpad.net/calibre/+bug/1866519)
This commit is contained in:
parent
b14e6c9a1f
commit
adf95e7a22
@ -465,3 +465,15 @@ def auto_scroll_action(action):
|
|||||||
elif action is 'resume':
|
elif action is 'resume':
|
||||||
auto_scroll_resume()
|
auto_scroll_resume()
|
||||||
return is_auto_scroll_active()
|
return is_auto_scroll_active()
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_selection_visible():
|
||||||
|
s = window.getSelection()
|
||||||
|
if not s.anchorNode:
|
||||||
|
return
|
||||||
|
p = s.anchorNode
|
||||||
|
while p:
|
||||||
|
if p.scrollIntoView:
|
||||||
|
p.scrollIntoView()
|
||||||
|
return
|
||||||
|
p = p.parentNode
|
||||||
|
@ -14,7 +14,7 @@ from read_book.flow_mode import (
|
|||||||
anchor_funcs as flow_anchor_funcs, auto_scroll_action as flow_auto_scroll_action,
|
anchor_funcs as flow_anchor_funcs, auto_scroll_action as flow_auto_scroll_action,
|
||||||
flow_onwheel, flow_to_scroll_fraction, handle_gesture as flow_handle_gesture,
|
flow_onwheel, flow_to_scroll_fraction, handle_gesture as flow_handle_gesture,
|
||||||
handle_shortcut as flow_handle_shortcut, layout as flow_layout,
|
handle_shortcut as flow_handle_shortcut, layout as flow_layout,
|
||||||
scroll_by_page as flow_scroll_by_page
|
scroll_by_page as flow_scroll_by_page, ensure_selection_visible
|
||||||
)
|
)
|
||||||
from read_book.footnotes import is_footnote_link
|
from read_book.footnotes import is_footnote_link
|
||||||
from read_book.globals import (
|
from read_book.globals import (
|
||||||
@ -581,7 +581,9 @@ class IframeBoss:
|
|||||||
|
|
||||||
def show_search_result(self, data, from_load):
|
def show_search_result(self, data, from_load):
|
||||||
if select_search_result(data.search_result):
|
if select_search_result(data.search_result):
|
||||||
if current_layout_mode() is not 'flow':
|
if current_layout_mode() is 'flow':
|
||||||
|
ensure_selection_visible()
|
||||||
|
else:
|
||||||
snap_to_selection()
|
snap_to_selection()
|
||||||
else:
|
else:
|
||||||
self.send_message('search_result_not_found', search_result=data.search_result)
|
self.send_message('search_result_not_found', search_result=data.search_result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user