forked from qt-creator/qt-creator
TextEditor: Fix jump to search result
Change-Id: Ie570936b0b96290d95999b8b501c12610ebfc9a8 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -3502,20 +3502,21 @@ bool TextEditorWidget::singleShotAfterHighlightingDone(std::function<void()> &&f
|
||||
[f = std::move(f)] { f(); }, Qt::SingleShotConnection);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TextEditorWidget::restoreState(const QByteArray &state)
|
||||
{
|
||||
if (singleShotAfterHighlightingDone([this, state] { restoreState(state); }))
|
||||
return;
|
||||
|
||||
const auto callFoldLicenseHeader = [this] {
|
||||
auto callFold = [this] {
|
||||
if (d->m_displaySettings.m_autoFoldFirstComment)
|
||||
d->foldLicenseHeader();
|
||||
};
|
||||
|
||||
if (!singleShotAfterHighlightingDone(callFold))
|
||||
callFold();
|
||||
};
|
||||
|
||||
if (state.isEmpty()) {
|
||||
callFoldLicenseHeader();
|
||||
return;
|
||||
@@ -3536,6 +3537,7 @@ void TextEditorWidget::restoreState(const QByteArray &state)
|
||||
if (version >= 1) {
|
||||
QList<int> collapsedBlocks;
|
||||
stream >> collapsedBlocks;
|
||||
auto foldingRestore = [this, collapsedBlocks] {
|
||||
QTextDocument *doc = document();
|
||||
bool layoutChanged = false;
|
||||
for (const int blockNumber : std::as_const(collapsedBlocks)) {
|
||||
@@ -3546,11 +3548,14 @@ void TextEditorWidget::restoreState(const QByteArray &state)
|
||||
}
|
||||
}
|
||||
if (layoutChanged) {
|
||||
auto documentLayout = qobject_cast<TextDocumentLayout*>(doc->documentLayout());
|
||||
QTC_ASSERT(documentLayout, return );
|
||||
auto documentLayout = qobject_cast<TextDocumentLayout *>(doc->documentLayout());
|
||||
QTC_ASSERT(documentLayout, return);
|
||||
documentLayout->requestUpdate();
|
||||
documentLayout->emitDocumentSizeChanged();
|
||||
}
|
||||
};
|
||||
if (!singleShotAfterHighlightingDone(foldingRestore))
|
||||
foldingRestore();
|
||||
} else {
|
||||
callFoldLicenseHeader();
|
||||
}
|
||||
|
Reference in New Issue
Block a user