diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 46144acb0f..6ad79e786f 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -894,7 +894,14 @@ class Boss(QObject): name = n break if name is not None and getattr(ed, 'syntax', None) == 'html': - self.gui.preview.show(name) + if self.gui.preview.show(name): + # The file being displayed by the preview has changed. + # Set the preview's position to the current cursor + # position in the editor, in case the editors' cursor + # position has not changed, since the last time it was + # focused. This is not inefficient since multiple requests + # to sync are de-bounced with a 100 msec wait. + self.sync_preview_to_editor() if name is not None: self.gui.file_list.mark_name_as_current(name) if ed.has_line_numbers: diff --git a/src/calibre/gui2/tweak_book/preview.py b/src/calibre/gui2/tweak_book/preview.py index 1371d4d2dd..cef89471e3 100644 --- a/src/calibre/gui2/tweak_book/preview.py +++ b/src/calibre/gui2/tweak_book/preview.py @@ -528,6 +528,7 @@ class Preview(QWidget): self.current_name = name parse_worker.add_request(name) self.view.setUrl(QUrl.fromLocalFile(current_container().name_to_abspath(name))) + return True def refresh(self): if self.current_name: