Commit 26d0c729 authored by Peter Kuemmel's avatar Peter Kuemmel Committed by Tobias Hunger

VCS base diff editor with merge conflicts

'git diff' marks merge conflicts different to changes.
With this fix it is possible to jump to the merge conflicts
also by a double click.

Task-number: QTCREATORBUG-6424
Change-Id: I355274e1ded4a05b3c7db718cbe9f48453070f82
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 3c350c93
......@@ -707,19 +707,23 @@ void VCSBaseEditorWidget::slotActivateAnnotation()
}
}
// Check for a change chunk "@@ -91,7 +95,7 @@" and return
// the modified line number (95).
// Note that git appends stuff after " @@" (function names, etc.).
static inline bool checkChunkLine(const QString &line, int *modifiedLineNumber)
{
if (!line.startsWith(QLatin1String("@@ ")))
// Check for a chunk of
// - changes : "@@ -91,7 +95,7 @@"
// - merged conflicts : "@@@ -91,7 +95,7 @@@"
// and return the modified line number (here 95).
// Note that git appends stuff after " @@"/" @@@" (function names, etc.).
static inline bool checkChunkLine(const QString &line, int *modifiedLineNumber, int numberOfAts)
{
const QString ats(numberOfAts, QLatin1Char('@'));
if (!line.startsWith(ats + QLatin1Char(' ')))
return false;
const int endPos = line.indexOf(QLatin1String(" @@"), 3);
const int len = ats.size() + 1;
const int endPos = line.indexOf(QLatin1Char(' ') + ats, len);
if (endPos == -1)
return false;
// the first chunk range applies to the original file, the second one to
// the modified file, the one we're interested int
const int plusPos = line.indexOf(QLatin1Char('+'), 3);
const int plusPos = line.indexOf(QLatin1Char('+'), len);
if (plusPos == -1 || plusPos > endPos)
return false;
const int lineNumberPos = plusPos + 1;
......@@ -732,6 +736,13 @@ static inline bool checkChunkLine(const QString &line, int *modifiedLineNumber)
return ok;
}
static inline bool checkChunkLine(const QString &line, int *modifiedLineNumber)
{
if (checkChunkLine(line, modifiedLineNumber, 2))
return true;
return checkChunkLine(line, modifiedLineNumber, 3);
}
void VCSBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
{
int chunkStart = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment