Fix preview not scrolling to anchor when clicking an internal link to another html file in the book

This commit is contained in:
Kovid Goyal 2018-07-29 15:52:13 +05:30
parent 92fe190f63
commit c9b2578b33
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 1 deletions

View file

@ -1261,7 +1261,7 @@ def link_clicked(self, name, anchor, show_anchor_not_found=False):
editor = self.edit_file(name, syntax)
if anchor and editor is not None:
if editor.go_to_anchor(anchor):
self.gui.preview.go_to_anchor(anchor)
self.gui.preview.pending_go_to_anchor = anchor
elif show_anchor_not_found:
error_dialog(self.gui, _('Not found'), _(
'The anchor %s was not found in this file') % anchor, show=True)

View file

@ -403,6 +403,7 @@ def __init__(self, parent=None):
self.view._page.bridge.request_sync.connect(self.request_sync)
self.view._page.bridge.request_split.connect(self.request_split)
self.view._page.loadFinished.connect(self.load_finished)
self.pending_go_to_anchor = None
self.inspector = self.view.inspector
l.addWidget(self.view)
self.bar = QToolBar(self)
@ -603,6 +604,9 @@ def stop_split(self):
actions['split-in-preview'].setChecked(False)
def load_finished(self, ok):
if self.pending_go_to_anchor:
self.view._page.go_to_anchor(self.pending_go_to_anchor)
self.pending_go_to_anchor = None
if actions['split-in-preview'].isChecked():
if ok:
self.do_start_split()