feature: update blame data when clicking/navigating commits (#1408)

* initial work on allowing navigation by clicking on commits in the blame window
* cleanup
This commit is contained in:
johanw1232 2025-06-10 03:30:12 +02:00 committed by GitHub
parent 11a46dbc93
commit 0ea4021a64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 108 additions and 9 deletions

View file

@ -42,8 +42,24 @@
</Grid>
<!-- File -->
<Border Grid.Row="1" Padding="8,0">
<TextBlock Text="{Binding Title}" VerticalAlignment="Center"/>
<Border Grid.Row="1" Padding="8,0" >
<Grid>
<TextBlock Text="{Binding Title}" VerticalAlignment="Center"/>
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
<Button Classes="icon_button"
IsEnabled="{Binding CanMoveBack}"
Width="28"
Click="HistoryBack">
<Path Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.TriangleLeft}"/>
</Button>
<Button Classes="icon_button"
IsEnabled="{Binding CanMoveForward}"
Width="28"
Click="HistoryForward">
<Path Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.TriangleRight}"/>
</Button>
</StackPanel>
</Grid>
</Border>
<!-- Body -->

View file

@ -225,7 +225,7 @@ namespace SourceGit.Views
{
if (DataContext is ViewModels.Blame blame)
{
blame.NavigateToCommit(info.CommitSHA);
blame.NavigateToCommit(info.CommitSHA, true);
}
e.Handled = true;
@ -433,6 +433,8 @@ namespace SourceGit.Views
public Blame()
{
InitializeComponent();
AddHandler(PointerReleasedEvent, MouseUpHandler, handledEventsToo: true);
}
protected override void OnClosed(EventArgs e)
@ -440,5 +442,32 @@ namespace SourceGit.Views
base.OnClosed(e);
GC.Collect();
}
private void HistoryBack(object _, RoutedEventArgs e)
{
if (DataContext is ViewModels.Blame blame)
{
blame.Back();
}
}
private void HistoryForward(object _, RoutedEventArgs e)
{
if (DataContext is ViewModels.Blame blame)
{
blame.Forward();
}
}
private void MouseUpHandler(object sender, PointerReleasedEventArgs e)
{
if (e.InitialPressMouseButton == MouseButton.XButton1)
{
HistoryBack(null, null);
}
else if (e.InitialPressMouseButton == MouseButton.XButton2)
{
HistoryForward(null, null);
}
}
}
}