mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-13 16:34:34 +12:00
Fixes #261: Manuskript response slow with recent addition of focus mode
This commit is contained in:
parent
5e2ac47dcc
commit
d521fc0771
|
@ -28,6 +28,7 @@ class MDEditView(textEditView):
|
||||||
self._textFormat = "md"
|
self._textFormat = "md"
|
||||||
self._highlighterClass = MarkdownHighlighter
|
self._highlighterClass = MarkdownHighlighter
|
||||||
self._noFocusMode = False
|
self._noFocusMode = False
|
||||||
|
self._lastCursorPosition = None
|
||||||
|
|
||||||
if index:
|
if index:
|
||||||
# We have to setup things anew, for the highlighter notably
|
# We have to setup things anew, for the highlighter notably
|
||||||
|
@ -174,8 +175,13 @@ class MDEditView(textEditView):
|
||||||
def cursorPositionHasChanged(self):
|
def cursorPositionHasChanged(self):
|
||||||
self.centerCursor()
|
self.centerCursor()
|
||||||
# Focus mode
|
# Focus mode
|
||||||
if self.highlighter:
|
if self.highlighter and settings.textEditor["focusMode"]:
|
||||||
QTimer.singleShot(50, self.highlighter.rehighlight)
|
if self._lastCursorPosition:
|
||||||
|
self.highlighter.onHighlightBlockAtPosition(
|
||||||
|
self._lastCursorPosition)
|
||||||
|
self._lastCursorPosition = self.textCursor().position()
|
||||||
|
self.highlighter.onHighlightBlockAtPosition(
|
||||||
|
self._lastCursorPosition)
|
||||||
|
|
||||||
def centerCursor(self, force=False):
|
def centerCursor(self, force=False):
|
||||||
cursor = self.cursorRect()
|
cursor = self.cursorRect()
|
||||||
|
|
Loading…
Reference in a new issue