forked from qt-creator/qt-creator
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:
@@ -113,7 +113,6 @@ void runSilverSeacher(FutureInterfaceType &fi, FileFindParameters parameters)
|
|||||||
process.setCommand({"ag", arguments});
|
process.setCommand({"ag", arguments});
|
||||||
process.start();
|
process.start();
|
||||||
if (process.waitForFinished()) {
|
if (process.waitForFinished()) {
|
||||||
typedef QList<FileSearchResult> FileSearchResultList;
|
|
||||||
QRegularExpression regexp;
|
QRegularExpression regexp;
|
||||||
if (parameters.flags & FindRegularExpression) {
|
if (parameters.flags & FindRegularExpression) {
|
||||||
const QRegularExpression::PatternOptions patternOptions
|
const QRegularExpression::PatternOptions patternOptions
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void OutputParserTest::test()
|
|||||||
QFETCH(QString, parserOutput);
|
QFETCH(QString, parserOutput);
|
||||||
QFETCH(FileSearchResultList, results);
|
QFETCH(FileSearchResultList, results);
|
||||||
SilverSearcher::SilverSearcherOutputParser ssop(parserOutput);
|
SilverSearcher::SilverSearcherOutputParser ssop(parserOutput);
|
||||||
const QList<Utils::FileSearchResult> items = ssop.parse();
|
const FileSearchResultList items = ssop.parse();
|
||||||
QCOMPARE(items, results);
|
QCOMPARE(items, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ SilverSearcherOutputParser::SilverSearcherOutputParser(
|
|||||||
hasRegexp = !regexp.pattern().isEmpty();
|
hasRegexp = !regexp.pattern().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Utils::FileSearchResult> SilverSearcherOutputParser::parse()
|
Utils::FileSearchResultList SilverSearcherOutputParser::parse()
|
||||||
{
|
{
|
||||||
while (index < outputSize - 1) {
|
while (index < outputSize - 1) {
|
||||||
if (output[index] == '\n') {
|
if (output[index] == '\n') {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class SilverSearcherOutputParser
|
|||||||
public:
|
public:
|
||||||
SilverSearcherOutputParser(const QString &output, const QRegularExpression ®exp = {});
|
SilverSearcherOutputParser(const QString &output, const QRegularExpression ®exp = {});
|
||||||
|
|
||||||
QList<Utils::FileSearchResult> parse();
|
Utils::FileSearchResultList parse();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int parseMatches();
|
int parseMatches();
|
||||||
@@ -32,7 +32,7 @@ private:
|
|||||||
int outputSize = 0;
|
int outputSize = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
Utils::FileSearchResult item;
|
Utils::FileSearchResult item;
|
||||||
QList<Utils::FileSearchResult> items;
|
Utils::FileSearchResultList items;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace SilverSearcher
|
} // namespace SilverSearcher
|
||||||
|
|||||||
@@ -6304,8 +6304,8 @@ void TextEditorWidgetPrivate::searchResultsReady(int beginIndex, int endIndex)
|
|||||||
{
|
{
|
||||||
QVector<SearchResult> results;
|
QVector<SearchResult> results;
|
||||||
for (int index = beginIndex; index < endIndex; ++index) {
|
for (int index = beginIndex; index < endIndex; ++index) {
|
||||||
const QList<Utils::FileSearchResult> resultList = m_searchWatcher->resultAt(index);
|
const FileSearchResultList resultList = m_searchWatcher->resultAt(index);
|
||||||
for (Utils::FileSearchResult result : resultList) {
|
for (FileSearchResult result : resultList) {
|
||||||
const QTextBlock &block = q->document()->findBlockByNumber(result.lineNumber - 1);
|
const QTextBlock &block = q->document()->findBlockByNumber(result.lineNumber - 1);
|
||||||
const int matchStart = block.position() + result.matchStart;
|
const int matchStart = block.position() + result.matchStart;
|
||||||
QTextCursor cursor(block);
|
QTextCursor cursor(block);
|
||||||
@@ -6360,9 +6360,9 @@ void TextEditorWidgetPrivate::highlightSearchResultsInScrollBar()
|
|||||||
adjustScrollBarRanges();
|
adjustScrollBarRanges();
|
||||||
|
|
||||||
m_searchWatcher = new QFutureWatcher<FileSearchResultList>();
|
m_searchWatcher = new QFutureWatcher<FileSearchResultList>();
|
||||||
connect(m_searchWatcher, &QFutureWatcher<Utils::FileSearchResultList>::resultsReadyAt,
|
connect(m_searchWatcher, &QFutureWatcher<FileSearchResultList>::resultsReadyAt,
|
||||||
this, &TextEditorWidgetPrivate::searchResultsReady);
|
this, &TextEditorWidgetPrivate::searchResultsReady);
|
||||||
connect(m_searchWatcher, &QFutureWatcher<Utils::FileSearchResultList>::finished,
|
connect(m_searchWatcher, &QFutureWatcher<FileSearchResultList>::finished,
|
||||||
this, &TextEditorWidgetPrivate::searchFinished);
|
this, &TextEditorWidgetPrivate::searchFinished);
|
||||||
m_searchWatcher->setPendingResultsLimit(10);
|
m_searchWatcher->setPendingResultsLimit(10);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user