mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Fixes bugs in focus mode (#259)
This commit is contained in:
parent
826d53933f
commit
46384b68eb
|
@ -105,7 +105,7 @@ class MarkdownHighlighter(BasicHighlighter):
|
|||
line = block.layout().lineAt(i)
|
||||
start = line.textStart()
|
||||
end = line.textStart() + line.textLength()
|
||||
if start <= pos < end:
|
||||
if start <= pos <= end:
|
||||
return (start, end)
|
||||
else:
|
||||
return True
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import re
|
||||
|
||||
from PyQt5.QtCore import QRegExp, Qt
|
||||
from PyQt5.QtCore import QRegExp, Qt, QTimer
|
||||
from PyQt5.QtGui import QTextCursor
|
||||
# from PyQt5.QtWidgets import
|
||||
|
||||
|
@ -173,6 +173,9 @@ class MDEditView(textEditView):
|
|||
|
||||
def cursorPositionHasChanged(self):
|
||||
self.centerCursor()
|
||||
# Focus mode
|
||||
if self.highlighter:
|
||||
QTimer.singleShot(50, self.highlighter.rehighlight)
|
||||
|
||||
def centerCursor(self, force=False):
|
||||
cursor = self.cursorRect()
|
||||
|
|
|
@ -67,9 +67,6 @@ class textEditView(QTextEdit):
|
|||
|
||||
# self.document().contentsChanged.connect(lambda: print(self.objectName(), "Contents changed"))
|
||||
|
||||
# Focus mode
|
||||
self.cursorPositionChanged.connect(self.cursorHasMoved)
|
||||
|
||||
self.setEnabled(False)
|
||||
|
||||
if index:
|
||||
|
@ -94,10 +91,6 @@ class textEditView(QTextEdit):
|
|||
self.highlighter = self._highlighterClass(self)
|
||||
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
|
||||
|
||||
def cursorHasMoved(self):
|
||||
if self.highlighter:
|
||||
self.highlighter.rehighlight()
|
||||
|
||||
def getDefaultLocale(self):
|
||||
default_locale = enchant.get_default_language()
|
||||
if default_locale is None:
|
||||
|
|
Loading…
Reference in a new issue