mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: text diff view go to next/prev change
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
52c7388a38
commit
882878dbe5
1 changed files with 20 additions and 22 deletions
|
@ -516,11 +516,16 @@ namespace SourceGit.Views
|
|||
firstLineIdx = index;
|
||||
}
|
||||
|
||||
if (firstLineIdx <= 1)
|
||||
return;
|
||||
|
||||
var firstLineType = lines[firstLineIdx].Type;
|
||||
var prevLineType = lines[firstLineIdx - 1].Type;
|
||||
var isChangeFirstLine = firstLineType != Models.TextDiffLineType.Normal && firstLineType != Models.TextDiffLineType.Indicator;
|
||||
if (isChangeFirstLine)
|
||||
var isChangePrevLine = prevLineType != Models.TextDiffLineType.Normal && prevLineType != Models.TextDiffLineType.Indicator;
|
||||
if (isChangeFirstLine && isChangePrevLine)
|
||||
{
|
||||
for (var i = firstLineIdx - 1; i >= 0; i--)
|
||||
for (var i = firstLineIdx - 2; i >= 0; i--)
|
||||
{
|
||||
var prevType = lines[i].Type;
|
||||
if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator)
|
||||
|
@ -530,33 +535,23 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
var findChange = false;
|
||||
for (var i = firstLineIdx - 1; i >= 0; i--)
|
||||
{
|
||||
var prevChangeEnd = -1;
|
||||
for (var i = firstLineIdx - 1; i >= 0; i--)
|
||||
var prevType = lines[i].Type;
|
||||
if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator)
|
||||
{
|
||||
var prevType = lines[i].Type;
|
||||
if (prevType == Models.TextDiffLineType.None ||
|
||||
prevType == Models.TextDiffLineType.Added ||
|
||||
prevType == Models.TextDiffLineType.Deleted)
|
||||
{
|
||||
prevChangeEnd = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevChangeEnd <= 0)
|
||||
return;
|
||||
|
||||
for (var i = prevChangeEnd - 1; i >= 0; i--)
|
||||
{
|
||||
var prevType = lines[i].Type;
|
||||
if (prevType == Models.TextDiffLineType.Normal || prevType == Models.TextDiffLineType.Indicator)
|
||||
if (findChange)
|
||||
{
|
||||
ScrollToLine(i + 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!findChange)
|
||||
{
|
||||
findChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,6 +573,9 @@ namespace SourceGit.Views
|
|||
lastLineIdx = index;
|
||||
}
|
||||
|
||||
if (lastLineIdx >= lines.Count - 1)
|
||||
return;
|
||||
|
||||
var lastLineType = lines[lastLineIdx].Type;
|
||||
var findNormalLine = lastLineType == Models.TextDiffLineType.Normal || lastLineType == Models.TextDiffLineType.Indicator;
|
||||
for (var idx = lastLineIdx + 1; idx < lines.Count; idx++)
|
||||
|
|
Loading…
Reference in a new issue