Skip to content

Commit 96a9019

Browse files
committed
Prev/next will (re-)scroll to first/last change-block in edge-cases
I.e when unset or already at first/last change-block (or the only one).
1 parent e0c219b commit 96a9019

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/ViewModels/DiffContext.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ public void PrevChange()
7878
if (_content is Models.TextDiff textDiff)
7979
{
8080
if (textDiff.CurrentChangeBlockIdx > 0)
81+
{
8182
textDiff.CurrentChangeBlockIdx--;
82-
else if (textDiff.CurrentChangeBlockIdx == -1 && textDiff.ChangeBlocks.Count > 0)
83-
textDiff.CurrentChangeBlockIdx = 0; // Jump to first change block
83+
}
84+
else if (textDiff.ChangeBlocks.Count > 0)
85+
{
86+
// Force property value change and (re-)jump to first change block
87+
textDiff.CurrentChangeBlockIdx = -1;
88+
textDiff.CurrentChangeBlockIdx = 0;
89+
}
8490
}
8591
}
8692

@@ -89,7 +95,15 @@ public void NextChange()
8995
if (_content is Models.TextDiff textDiff)
9096
{
9197
if (textDiff.CurrentChangeBlockIdx < textDiff.ChangeBlocks.Count - 1)
98+
{
9299
textDiff.CurrentChangeBlockIdx++;
100+
}
101+
else if (textDiff.ChangeBlocks.Count > 0)
102+
{
103+
// Force property value change and (re-)jump to last change block
104+
textDiff.CurrentChangeBlockIdx = -1;
105+
textDiff.CurrentChangeBlockIdx = textDiff.ChangeBlocks.Count - 1;
106+
}
93107
}
94108
}
95109

0 commit comments

Comments
 (0)