Reuse FileSearchResultList

Change-Id: I2a20167faf78fcfa3b4bf392a42e0a72d92cd68e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-09-06 16:53:57 +02:00
parent d8fcaf0a73
commit dbfdd334b5
5 changed files with 8 additions and 9 deletions

View File

@@ -113,7 +113,6 @@ void runSilverSeacher(FutureInterfaceType &fi, FileFindParameters parameters)
process.setCommand({"ag", arguments});
process.start();
if (process.waitForFinished()) {
typedef QList<FileSearchResult> FileSearchResultList;
QRegularExpression regexp;
if (parameters.flags & FindRegularExpression) {
const QRegularExpression::PatternOptions patternOptions

View File

@@ -51,7 +51,7 @@ void OutputParserTest::test()
QFETCH(QString, parserOutput);
QFETCH(FileSearchResultList, results);
SilverSearcher::SilverSearcherOutputParser ssop(parserOutput);
const QList<Utils::FileSearchResult> items = ssop.parse();
const FileSearchResultList items = ssop.parse();
QCOMPARE(items, results);
}

View File

@@ -16,7 +16,7 @@ SilverSearcherOutputParser::SilverSearcherOutputParser(
hasRegexp = !regexp.pattern().isEmpty();
}
QList<Utils::FileSearchResult> SilverSearcherOutputParser::parse()
Utils::FileSearchResultList SilverSearcherOutputParser::parse()
{
while (index < outputSize - 1) {
if (output[index] == '\n') {

View File

@@ -16,7 +16,7 @@ class SilverSearcherOutputParser
public:
SilverSearcherOutputParser(const QString &output, const QRegularExpression &regexp = {});
QList<Utils::FileSearchResult> parse();
Utils::FileSearchResultList parse();
private:
int parseMatches();
@@ -32,7 +32,7 @@ private:
int outputSize = 0;
int index = 0;
Utils::FileSearchResult item;
QList<Utils::FileSearchResult> items;
Utils::FileSearchResultList items;
};
} // namespace SilverSearcher

View File

@@ -6304,8 +6304,8 @@ void TextEditorWidgetPrivate::searchResultsReady(int beginIndex, int endIndex)
{
QVector<SearchResult> results;
for (int index = beginIndex; index < endIndex; ++index) {
const QList<Utils::FileSearchResult> resultList = m_searchWatcher->resultAt(index);
for (Utils::FileSearchResult result : resultList) {
const FileSearchResultList resultList = m_searchWatcher->resultAt(index);
for (FileSearchResult result : resultList) {
const QTextBlock &block = q->document()->findBlockByNumber(result.lineNumber - 1);
const int matchStart = block.position() + result.matchStart;
QTextCursor cursor(block);
@@ -6360,9 +6360,9 @@ void TextEditorWidgetPrivate::highlightSearchResultsInScrollBar()
adjustScrollBarRanges();
m_searchWatcher = new QFutureWatcher<FileSearchResultList>();
connect(m_searchWatcher, &QFutureWatcher<Utils::FileSearchResultList>::resultsReadyAt,
connect(m_searchWatcher, &QFutureWatcher<FileSearchResultList>::resultsReadyAt,
this, &TextEditorWidgetPrivate::searchResultsReady);
connect(m_searchWatcher, &QFutureWatcher<Utils::FileSearchResultList>::finished,
connect(m_searchWatcher, &QFutureWatcher<FileSearchResultList>::finished,
this, &TextEditorWidgetPrivate::searchFinished);
m_searchWatcher->setPendingResultsLimit(10);