aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/syntaxhighlighter.cpp
diff options
context:
space:
mode:
authorArtem Sokolovskii <artem.sokolovskii@qt.io>2024-02-12 11:10:04 +0100
committerArtem Sokolovskii <artem.sokolovskii@qt.io>2024-03-06 11:52:41 +0000
commitbb87db09e287a2e60782d8eb212586415a630f98 (patch)
treec8b74996970d0f278616589280238bc70a1bf12c /src/plugins/texteditor/syntaxhighlighter.cpp
parente31a06a0f42143724ebf35aa2cc669dbcf54fbf0 (diff)
SyntaxHighlighter: Add rerun if highlighting was interrupted
Added mechanism of highlighting restart when the previous highlighting was interrupted. Change-Id: Ic44c06442fd9f0002fed760472d5d39903e7ef50 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/syntaxhighlighter.cpp')
-rw-r--r--src/plugins/texteditor/syntaxhighlighter.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp
index 34f4b1c777..f7db190852 100644
--- a/src/plugins/texteditor/syntaxhighlighter.cpp
+++ b/src/plugins/texteditor/syntaxhighlighter.cpp
@@ -206,8 +206,11 @@ void SyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int ch
vecRes << resStart;
while (block.isValid() && (block.position() < endPosition || forceHighlightOfNextBlock)) {
- if (QThread::currentThread()->isInterruptionRequested())
- break;
+ if (QThread::currentThread()->isInterruptionRequested() || q->isInterrupted()) {
+ inReformatBlocks = false;
+ emit q->resultsReady({});
+ return;
+ }
const int stateBeforeHighlight = block.userState();
@@ -767,9 +770,7 @@ void SyntaxHighlighter::setExtraFormats(const QTextBlock &block,
res.m_formatRanges = block.layout()->formats();
res.fillByBlock(block);
res.m_state = SyntaxHighlighter::State::Extras;
- SyntaxHighlighter::Result resDone;
- resDone.m_state = SyntaxHighlighter::State::Done;
- emit resultsReady({res, resDone});
+ emit resultsReady({std::move(res)});
document()->markContentsDirty(block.position(), blockLength - 1);
d->inReformatBlocks = wasInReformatBlocks;
@@ -796,9 +797,7 @@ void SyntaxHighlighter::clearExtraFormats(const QTextBlock &block)
res.m_formatRanges = block.layout()->formats();
res.fillByBlock(block);
res.m_state = SyntaxHighlighter::State::Extras;
- SyntaxHighlighter::Result resDone;
- resDone.m_state = SyntaxHighlighter::State::Done;
- emit resultsReady({res, resDone});
+ emit resultsReady({std::move(res)});
document()->markContentsDirty(block.position(), blockLength - 1);
d->inReformatBlocks = wasInReformatBlocks;