diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 1410c7b4..14f1db91 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -223,21 +223,12 @@ class GuiDocEditor(QTextEdit): # font changed, otherwise we just clear the editor entirely, # which makes it read only. if self.theHandle is not None: - self.reloadText() + self.redrawText() else: self.clearEditor() 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): """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 @@ -297,6 +288,21 @@ class GuiDocEditor(QTextEdit): 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): """Replaces the text of the current document with the provided text. This also clears undo history. diff --git a/nw/guimain.py b/nw/guimain.py index 5f237bb7..62b2db74 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -716,13 +716,13 @@ class GuiMain(QMainWindow): tEnd = time() self.statusBar.setStatus("Indexing completed in %.1f ms" % ((tEnd - tStart)*1000.0)) - self.docEditor.reloadText() - qApp.restoreOverrideCursor() if not beQuiet: self.makeAlert("The project index has been successfully rebuilt.", nwAlert.INFO) + self.docEditor.reHighLightText() + return True def rebuildOutline(self):