Drop the doceditor reloadText function as it resets undo stack

This commit is contained in:
Veronica K. B. Olsen
2020-10-05 20:54:19 +02:00
parent eb67582313
commit efdf88be66
2 changed files with 18 additions and 12 deletions
+16 -10
View File
@@ -223,21 +223,12 @@ class GuiDocEditor(QTextEdit):
# font changed, otherwise we just clear the editor entirely, # font changed, otherwise we just clear the editor entirely,
# which makes it read only. # which makes it read only.
if self.theHandle is not None: if self.theHandle is not None:
self.reloadText() self.redrawText()
else: else:
self.clearEditor() self.clearEditor()
return True return True
def reloadText(self):
"""Reloads the document currently being edited.
"""
if self.theHandle is not None:
tHandle = self.theHandle
self.clearEditor()
self.loadText(tHandle, showStatus=False)
return
def loadText(self, tHandle, tLine=None, showStatus=True): def loadText(self, tHandle, tLine=None, showStatus=True):
"""Load text from a document into the editor. If we have an io """Load text from a document into the editor. If we have an io
error, we must handle this and clear the editor so that we don't error, we must handle this and clear the editor so that we don't
@@ -297,6 +288,21 @@ class GuiDocEditor(QTextEdit):
return True return True
def reHighLightText(self, forceBigDoc=False):
"""Run the syntax highlighter again.
"""
if not self.bigDoc or forceBigDoc:
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
self.hLight.rehighlight()
qApp.restoreOverrideCursor()
return
def redrawText(self):
"""Redraw the text by marking the document content as "dirty".
"""
self.qDocument.markContentsDirty(0, self.qDocument.characterCount())
return
def replaceText(self, theText): def replaceText(self, theText):
"""Replaces the text of the current document with the provided """Replaces the text of the current document with the provided
text. This also clears undo history. text. This also clears undo history.
+2 -2
View File
@@ -716,13 +716,13 @@ class GuiMain(QMainWindow):
tEnd = time() tEnd = time()
self.statusBar.setStatus("Indexing completed in %.1f ms" % ((tEnd - tStart)*1000.0)) self.statusBar.setStatus("Indexing completed in %.1f ms" % ((tEnd - tStart)*1000.0))
self.docEditor.reloadText()
qApp.restoreOverrideCursor() qApp.restoreOverrideCursor()
if not beQuiet: if not beQuiet:
self.makeAlert("The project index has been successfully rebuilt.", nwAlert.INFO) self.makeAlert("The project index has been successfully rebuilt.", nwAlert.INFO)
self.docEditor.reHighLightText()
return True return True
def rebuildOutline(self): def rebuildOutline(self):