Ensure cursor is visible after showing or closing the document viewer (#1302)

This commit is contained in:
Veronica Berglyd Olsen
2023-11-18 15:56:03 +01:00
parent 208b9334e1
commit 83187c517f
+13
View File
@@ -688,6 +688,7 @@ class GuiMain(QMainWindow):
logger.debug("Viewing document with handle '%s'", tHandle)
if self.docViewer.loadText(tHandle):
if not self.splitView.isVisible():
cursorVisible = self.docEditor.cursorIsVisible()
bPos = self.splitMain.sizes()
self.splitView.setVisible(True)
vPos = [0, 0]
@@ -696,6 +697,11 @@ class GuiMain(QMainWindow):
self.splitDocs.setSizes(vPos)
self.docViewerPanel.setVisible(CONFIG.showViewerPanel)
# Since editor width changes, we need to make sure we
# restore cursor visibility in the editor. See #1302
if cursorVisible:
self.docEditor.ensureCursorVisibleNoCentre()
if sTitle:
self.docViewer.navigateTo(f"#{sTitle}")
@@ -1113,11 +1119,18 @@ class GuiMain(QMainWindow):
# Only reset the last handle if the user called this
SHARED.project.data.setLastHandle(None, "viewer")
cursorVisible = self.docEditor.cursorIsVisible()
# Hide the panel
bPos = self.splitMain.sizes()
self.splitView.setVisible(False)
self.splitDocs.setSizes([bPos[1], 0])
# Since editor width changes, we need to make sure we restore
# cursor visibility in the editor. See #1302
if cursorVisible:
self.docEditor.ensureCursorVisibleNoCentre()
return not self.splitView.isVisible()
def toggleFullScreenMode(self) -> None: