forked from qt-creator/qt-creator
DiffEditor: Fix DiffEditor tests
Amends 5ff073df19
Change-Id: I4597453b057dfce41b73b4973205cba33d8e4a58
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -936,7 +936,7 @@ QString Diff::toString() const
|
||||
|
||||
///////////////
|
||||
|
||||
Differ::Differ(const QFuture<void> &future)
|
||||
Differ::Differ(const std::optional<QFuture<void>> &future)
|
||||
: m_future(future)
|
||||
{
|
||||
}
|
||||
@@ -1073,7 +1073,7 @@ QList<Diff> Differ::diffMyers(const QString &text1, const QString &text2)
|
||||
int kMinReverse = -D;
|
||||
int kMaxReverse = D;
|
||||
for (int d = 0; d <= D; d++) {
|
||||
if (m_future.isCanceled()) {
|
||||
if (m_future && m_future->isCanceled()) {
|
||||
delete [] forwardV;
|
||||
delete [] reverseV;
|
||||
return QList<Diff>();
|
||||
@@ -1192,7 +1192,7 @@ QList<Diff> Differ::diffNonCharMode(const QString &text1, const QString &text2)
|
||||
QString lastInsert;
|
||||
QList<Diff> newDiffList;
|
||||
for (int i = 0; i <= diffList.count(); i++) {
|
||||
if (m_future.isCanceled()) {
|
||||
if (m_future && m_future->isCanceled()) {
|
||||
m_currentDiffMode = diffMode;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <QFuture>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
template <class K, class T>
|
||||
class QMap;
|
||||
@@ -42,7 +44,7 @@ public:
|
||||
WordMode,
|
||||
LineMode
|
||||
};
|
||||
Differ(const QFuture<void> &future = {});
|
||||
Differ(const std::optional<QFuture<void>> &future = {});
|
||||
QList<Diff> diff(const QString &text1, const QString &text2);
|
||||
QList<Diff> unifiedDiff(const QString &text1, const QString &text2);
|
||||
void setDiffMode(DiffMode mode);
|
||||
@@ -90,7 +92,7 @@ private:
|
||||
int subTextStart);
|
||||
DiffMode m_diffMode = Differ::LineMode;
|
||||
DiffMode m_currentDiffMode = Differ::LineMode;
|
||||
QFuture<void> m_future;
|
||||
std::optional<QFuture<void>> m_future;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
@@ -557,7 +557,7 @@ static QList<RowData> readLines(QStringView patch, bool lastChunk, bool *lastChu
|
||||
int noNewLineInDelete = -1;
|
||||
int noNewLineInInsert = -1;
|
||||
|
||||
const QVector<QStringView> lines = patch.split(newLine);
|
||||
const QList<QStringView> lines = patch.split(newLine);
|
||||
int i;
|
||||
for (i = 0; i < lines.size(); i++) {
|
||||
QStringView line = lines.at(i);
|
||||
@@ -795,7 +795,7 @@ static QList<ChunkData> readChunks(QStringView patch, bool *lastChunkAtTheEndOfF
|
||||
QList<ChunkData> chunkDataList;
|
||||
int position = -1;
|
||||
|
||||
QVector<int> startingPositions; // store starting positions of @@
|
||||
QList<int> startingPositions; // store starting positions of @@
|
||||
if (patch.startsWith(QStringLiteral("@@ -")))
|
||||
startingPositions.append(position + 1);
|
||||
|
||||
@@ -1199,7 +1199,7 @@ static void readGitPatch(QPromise<QList<FileData>> &promise, QStringView patch)
|
||||
{
|
||||
int position = -1;
|
||||
|
||||
QVector<int> startingPositions; // store starting positions of git headers
|
||||
QList<int> startingPositions; // store starting positions of git headers
|
||||
if (patch.startsWith(QStringLiteral("diff --git ")))
|
||||
startingPositions.append(position + 1);
|
||||
|
||||
@@ -1214,7 +1214,7 @@ static void readGitPatch(QPromise<QList<FileData>> &promise, QStringView patch)
|
||||
|
||||
const QChar newLine('\n');
|
||||
|
||||
QVector<PatchInfo> patches;
|
||||
QList<PatchInfo> patches;
|
||||
const int count = startingPositions.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (promise.isCanceled())
|
||||
@@ -1239,10 +1239,12 @@ static void readGitPatch(QPromise<QList<FileData>> &promise, QStringView patch)
|
||||
patches.append(PatchInfo { remainingFileDiff, fileData });
|
||||
}
|
||||
|
||||
if (patches.isEmpty())
|
||||
return;
|
||||
|
||||
promise.setProgressRange(0, patches.size());
|
||||
|
||||
QList<FileData> fileDataList;
|
||||
bool readOk = false;
|
||||
int i = 0;
|
||||
for (const auto &patchInfo : std::as_const(patches)) {
|
||||
if (promise.isCanceled())
|
||||
@@ -1250,6 +1252,7 @@ static void readGitPatch(QPromise<QList<FileData>> &promise, QStringView patch)
|
||||
promise.setProgressValue(i++);
|
||||
|
||||
FileData fileData = patchInfo.fileData;
|
||||
bool readOk = false;
|
||||
if (!patchInfo.patch.isEmpty() || fileData.fileOperation == FileData::ChangeFile)
|
||||
fileData.chunks = readChunks(patchInfo.patch, &fileData.lastChunkAtTheEndOfFile, &readOk);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user