mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 05:10:25 +08:00
feature: add added/removed line counts to diff view (#2194)
This commit is contained in:
@@ -194,6 +194,7 @@ namespace SourceGit.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
_result.TextDiff.DeletedLines++;
|
||||
_last = new Models.TextDiffLine(Models.TextDiffLineType.Deleted, line.Substring(1), _oldLine, 0);
|
||||
_deleted.Add(_last);
|
||||
_oldLine++;
|
||||
@@ -207,6 +208,7 @@ namespace SourceGit.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
_result.TextDiff.AddedLines++;
|
||||
_last = new Models.TextDiffLine(Models.TextDiffLineType.Added, line.Substring(1), 0, _newLine);
|
||||
_added.Add(_last);
|
||||
_newLine++;
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace SourceGit.Models
|
||||
{
|
||||
public List<TextDiffLine> Lines { get; set; } = new List<TextDiffLine>();
|
||||
public int MaxLineNumber = 0;
|
||||
public int AddedLines { get; set; } = 0;
|
||||
public int DeletedLines { get; set; } = 0;
|
||||
|
||||
public TextDiffSelection MakeSelection(int startLine, int endLine, bool isCombined, bool isOldSide)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace SourceGit.ViewModels
|
||||
{
|
||||
public Models.DiffOption Option => _option;
|
||||
public Models.TextDiff Data => _data;
|
||||
public int AddedLines => _data?.AddedLines ?? 0;
|
||||
public int DeletedLines => _data?.DeletedLines ?? 0;
|
||||
|
||||
public Vector ScrollOffset
|
||||
{
|
||||
|
||||
@@ -67,7 +67,29 @@
|
||||
<ContentControl Content="{Binding Content, Mode=OneWay}" IsVisible="{Binding IsTextDiff}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:TextDiffContext">
|
||||
<TextBlock Margin="0,0,0,0" FontSize="11" Text="{Binding BlockNavigation.Indicator}"/>
|
||||
<StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">
|
||||
<TextBlock Margin="0,0,0,0" FontSize="11" Text="{Binding BlockNavigation.Indicator}"/>
|
||||
<Border Height="16"
|
||||
Background="{DynamicResource Brush.Diff.AddedBG}"
|
||||
CornerRadius="8"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding AddedLines, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
|
||||
<TextBlock FontSize="10"
|
||||
Margin="8,0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
Text="{Binding AddedLines, StringFormat=+{0}}"/>
|
||||
</Border>
|
||||
<Border Height="16"
|
||||
Background="{DynamicResource Brush.Diff.DeletedBG}"
|
||||
CornerRadius="8"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding DeletedLines, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
|
||||
<TextBlock FontSize="10"
|
||||
Margin="8,0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
Text="{Binding DeletedLines, StringFormat=-{0}}"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
Reference in New Issue
Block a user