Fix preview position not correct when switching back to a previously opened editor

This commit is contained in:
Kovid Goyal 2013-12-11 22:53:07 +05:30
parent c6dadb7100
commit df97799deb
2 changed files with 9 additions and 1 deletions

View File

@ -894,7 +894,14 @@ class Boss(QObject):
name = n name = n
break break
if name is not None and getattr(ed, 'syntax', None) == 'html': 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: if name is not None:
self.gui.file_list.mark_name_as_current(name) self.gui.file_list.mark_name_as_current(name)
if ed.has_line_numbers: if ed.has_line_numbers:

View File

@ -528,6 +528,7 @@ class Preview(QWidget):
self.current_name = name self.current_name = name
parse_worker.add_request(name) parse_worker.add_request(name)
self.view.setUrl(QUrl.fromLocalFile(current_container().name_to_abspath(name))) self.view.setUrl(QUrl.fromLocalFile(current_container().name_to_abspath(name)))
return True
def refresh(self): def refresh(self):
if self.current_name: if self.current_name: