Minor changes to document re-highlighting

This commit is contained in:
Veronica K. B. Olsen
2020-10-07 20:20:59 +02:00
parent dc5da378ed
commit 8bbdbde7ca
2 changed files with 10 additions and 4 deletions
+8 -1
View File
@@ -28,6 +28,8 @@
import nw
import logging
from time import time
from PyQt5.QtCore import Qt, QRegularExpression
from PyQt5.QtGui import (
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
@@ -244,10 +246,15 @@ class GuiDocHighlighter(QSyntaxHighlighter):
"""
qDocument = self.document()
nBlocks = qDocument.blockCount()
bfTime = time()
for i in range(nBlocks):
theBlock = qDocument.findBlockByNumber(i)
if theBlock.userState() & theType == theType:
if theBlock.userState() & theType > 0:
self.rehighlightBlock(theBlock)
afTime = time()
logger.debug(
"Document highlighted in %.3f ms" % (1000*(afTime-bfTime))
)
return
##