forked from qt-creator/qt-creator
TextEditor: Fix folding for async syntax highlighter
- Made restoreState, ensureBlockIsUnfolded, fold, unfold and unfoldAll functions to be called only after highlighting is done - Improved management of foldValidator in async case - Removed optimizations in cpphighlighter and glshighlighter. The highlighters are async now and optimization is not necessary. In these optimizations in the function highlightBlock the highlighting changes not only for currentBlock but and for several next. Which is contradict with the function name. Change-Id: Ib413e6b982eb39d52f36c3066ff0fa8c28fbe231 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -81,6 +81,10 @@ void SyntaxHighlighter::delayedRehighlight()
|
||||
if (!d->rehighlightPending)
|
||||
return;
|
||||
d->rehighlightPending = false;
|
||||
|
||||
if (document()->isEmpty())
|
||||
return;
|
||||
|
||||
rehighlight();
|
||||
}
|
||||
|
||||
@@ -197,6 +201,10 @@ void SyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int ch
|
||||
|
||||
QList<SyntaxHighlighter::Result> vecRes;
|
||||
|
||||
SyntaxHighlighter::Result resStart;
|
||||
resStart.m_state = SyntaxHighlighter::State::Start;
|
||||
vecRes << resStart;
|
||||
|
||||
while (block.isValid() && (block.position() < endPosition || forceHighlightOfNextBlock)) {
|
||||
if (QThread::currentThread()->isInterruptionRequested())
|
||||
break;
|
||||
@@ -758,7 +766,10 @@ void SyntaxHighlighter::setExtraFormats(const QTextBlock &block,
|
||||
SyntaxHighlighter::Result res;
|
||||
res.m_formatRanges = block.layout()->formats();
|
||||
res.fillByBlock(block);
|
||||
emit resultsReady({res});
|
||||
res.m_state = SyntaxHighlighter::State::Extras;
|
||||
SyntaxHighlighter::Result resDone;
|
||||
resDone.m_state = SyntaxHighlighter::State::Done;
|
||||
emit resultsReady({res, resDone});
|
||||
|
||||
document()->markContentsDirty(block.position(), blockLength - 1);
|
||||
d->inReformatBlocks = wasInReformatBlocks;
|
||||
@@ -784,7 +795,10 @@ void SyntaxHighlighter::clearExtraFormats(const QTextBlock &block)
|
||||
SyntaxHighlighter::Result res;
|
||||
res.m_formatRanges = block.layout()->formats();
|
||||
res.fillByBlock(block);
|
||||
emit resultsReady({res});
|
||||
res.m_state = SyntaxHighlighter::State::Extras;
|
||||
SyntaxHighlighter::Result resDone;
|
||||
resDone.m_state = SyntaxHighlighter::State::Done;
|
||||
emit resultsReady({res, resDone});
|
||||
|
||||
document()->markContentsDirty(block.position(), blockLength - 1);
|
||||
d->inReformatBlocks = wasInReformatBlocks;
|
||||
|
||||
Reference in New Issue
Block a user