Fixes #261: Manuskript response slow with recent addition of focus mode

This commit is contained in:
Olivier Keshavjee 2017-12-06 18:41:26 +01:00
parent 5e2ac47dcc
commit d521fc0771

View file

@ -28,6 +28,7 @@ class MDEditView(textEditView):
self._textFormat = "md"
self._highlighterClass = MarkdownHighlighter
self._noFocusMode = False
self._lastCursorPosition = None
if index:
# We have to setup things anew, for the highlighter notably
@ -174,8 +175,13 @@ class MDEditView(textEditView):
def cursorPositionHasChanged(self):
self.centerCursor()
# Focus mode
if self.highlighter:
QTimer.singleShot(50, self.highlighter.rehighlight)
if self.highlighter and settings.textEditor["focusMode"]:
if self._lastCursorPosition:
self.highlighter.onHighlightBlockAtPosition(
self._lastCursorPosition)
self._lastCursorPosition = self.textCursor().position()
self.highlighter.onHighlightBlockAtPosition(
self._lastCursorPosition)
def centerCursor(self, force=False):
cursor = self.cursorRect()