Answer the question
In order to leave comments, you need to log in
Why does setFormat in hightlight take 20 times longer when opening a document than when inserting text?
Given:
Yes . It is set in __init__ among other thingsclass MyEdit(QPlainTextEdit)
self.highlight = HL_Syntax.GMHighlighter(self.document())
class GMHighlighter (QSyntaxHighlighter)
def highlightBlock(self, text):
...
self.setFormat(index, length, format)
self.highlight = HL_Syntax.GMHighlighter(self.document())
MyEdit
a millionaire file , it takes 14 seconds to insert the same text into an empty one . That is, everything is relatively fast, but opening is faster than Ctrl + V .
If you turn on syntax recognition, but do not turn on visual highlighting (without ), then 35 seconds are added to both results , which is logical.
However, it is worth turning it on and strangeness begins - Ctrl + V adds another six seconds , and opening the file instantly slows down at times and takes more than three minutes .MyEdit
setFormat
self.setFormat(index, length, format)
def updateLineNumberArea(self, rect, dy):
if dy:
self.lineNumberArea.scroll(0, dy)
else:
self.lineNumberArea.update(0, rect.y(), self.lineNumberArea.width(), rect.height())
if rect.contains(self.viewport().rect()):
self.updateLineNumberAreaWidth(0)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question