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);
|
[f = std::move(f)] { f(); }, Qt::SingleShotConnection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorWidget::restoreState(const QByteArray &state)
|
void TextEditorWidget::restoreState(const QByteArray &state)
|
||||||
{
|
{
|
||||||
if (singleShotAfterHighlightingDone([this, state] { restoreState(state); }))
|
|
||||||
return;
|
|
||||||
|
|
||||||
const auto callFoldLicenseHeader = [this] {
|
const auto callFoldLicenseHeader = [this] {
|
||||||
|
auto callFold = [this] {
|
||||||
if (d->m_displaySettings.m_autoFoldFirstComment)
|
if (d->m_displaySettings.m_autoFoldFirstComment)
|
||||||
d->foldLicenseHeader();
|
d->foldLicenseHeader();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!singleShotAfterHighlightingDone(callFold))
|
||||||
|
callFold();
|
||||||
|
};
|
||||||
|
|
||||||
if (state.isEmpty()) {
|
if (state.isEmpty()) {
|
||||||
callFoldLicenseHeader();
|
callFoldLicenseHeader();
|
||||||
return;
|
return;
|
||||||
@@ -3536,6 +3537,7 @@ void TextEditorWidget::restoreState(const QByteArray &state)
|
|||||||
if (version >= 1) {
|
if (version >= 1) {
|
||||||
QList<int> collapsedBlocks;
|
QList<int> collapsedBlocks;
|
||||||
stream >> collapsedBlocks;
|
stream >> collapsedBlocks;
|
||||||
|
auto foldingRestore = [this, collapsedBlocks] {
|
||||||
QTextDocument *doc = document();
|
QTextDocument *doc = document();
|
||||||
bool layoutChanged = false;
|
bool layoutChanged = false;
|
||||||
for (const int blockNumber : std::as_const(collapsedBlocks)) {
|
for (const int blockNumber : std::as_const(collapsedBlocks)) {
|
||||||
@@ -3551,6 +3553,9 @@ void TextEditorWidget::restoreState(const QByteArray &state)
|
|||||||
documentLayout->requestUpdate();
|
documentLayout->requestUpdate();
|
||||||
documentLayout->emitDocumentSizeChanged();
|
documentLayout->emitDocumentSizeChanged();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if (!singleShotAfterHighlightingDone(foldingRestore))
|
||||||
|
foldingRestore();
|
||||||
} else {
|
} else {
|
||||||
callFoldLicenseHeader();
|
callFoldLicenseHeader();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user