Skip to content

Commit 9dc4fa3

Browse files
committed
Added indicator of current/total change-blocks in DiffView toolbar
1 parent ef62e8e commit 9dc4fa3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/ViewModels/DiffContext.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public int UnifiedLines
5151
private set => SetProperty(ref _unifiedLines, value);
5252
}
5353

54+
public string ChangeBlockIndicator
55+
{
56+
get => _changeBlockIndicator;
57+
private set => SetProperty(ref _changeBlockIndicator, value);
58+
}
59+
5460
public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null)
5561
{
5662
_repo = repo;
@@ -88,6 +94,7 @@ public void PrevChange()
8894
textDiff.CurrentChangeBlockIdx = 0;
8995
}
9096
}
97+
RefreshChangeBlockIndicator();
9198
}
9299

93100
public void NextChange()
@@ -104,7 +111,20 @@ public void NextChange()
104111
textDiff.CurrentChangeBlockIdx = -1;
105112
textDiff.CurrentChangeBlockIdx = textDiff.ChangeBlocks.Count - 1;
106113
}
114+
RefreshChangeBlockIndicator();
115+
}
116+
}
117+
118+
public void RefreshChangeBlockIndicator()
119+
{
120+
string curr = "-", tot = "-";
121+
if (_content is Models.TextDiff textDiff)
122+
{
123+
if (textDiff.CurrentChangeBlockIdx >= 0)
124+
curr = (textDiff.CurrentChangeBlockIdx + 1).ToString();
125+
tot = (textDiff.ChangeBlocks.Count).ToString();
107126
}
127+
ChangeBlockIndicator = curr + "/" + tot;
108128
}
109129

110130
public void ToggleFullTextDiff()
@@ -251,7 +271,9 @@ private void LoadDiffContent()
251271
FileModeChange = latest.FileModeChange;
252272
Content = rs;
253273
IsTextDiff = rs is Models.TextDiff;
254-
});
274+
275+
RefreshChangeBlockIndicator();
276+
});
255277
});
256278
}
257279

@@ -315,6 +337,7 @@ public bool IsSame(Info other)
315337
private string _title;
316338
private string _fileModeChange = string.Empty;
317339
private int _unifiedLines = 4;
340+
private string _changeBlockIndicator = "-/-";
318341
private bool _isTextDiff = false;
319342
private bool _ignoreWhitespace = false;
320343
private object _content = null;

src/Views/DiffView.axaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
4343
</Button>
4444

45+
<TextBlock Classes="primary"
46+
Margin="0,0,0,0"
47+
Text="{Binding ChangeBlockIndicator}"
48+
FontSize="11"
49+
TextTrimming="CharacterEllipsis"
50+
IsVisible="{Binding IsTextDiff}"/>
51+
4552
<Button Classes="icon_button"
4653
Width="28"
4754
Click="OnGotoNextChange"

0 commit comments

Comments
 (0)