Merge pull request #621 from vkbo/issue608_cursor_in_blank_doc

Issue #608: Missing Cursor
This commit is contained in:
Veronica K. Berglyd Olsen
2021-01-29 22:08:59 +00:00
committed by GitHub
+9 -3
View File
@@ -345,9 +345,14 @@ class GuiDocEditor(QTextEdit):
qApp.processEvents()
self.setDocumentChanged(False)
qApp.restoreOverrideCursor()
# This is a hack to fix invisble cursor on an empty document
if self.qDocument.characterCount() <= 1:
self.setPlainText("\n")
self.setPlainText("")
self.setCursorPosition(0)
return True
def updateTagHighLighting(self, forceBigDoc=False):
@@ -513,9 +518,10 @@ class GuiDocEditor(QTextEdit):
if not isinstance(thePosition, int):
return False
if thePosition >= 0:
nChars = self.qDocument.characterCount()
if nChars > 1:
theCursor = self.textCursor()
theCursor.setPosition(thePosition)
theCursor.setPosition(min(max(thePosition, 0), nChars-1))
self.setTextCursor(theCursor)
self.docFooter.updateLineCount()