optimize<Blame>: only navigate to commit when user clicked the commit SHA

This commit is contained in:
leo 2023-08-28 10:17:10 +08:00
parent 24957b8c86
commit 6e624797ae
2 changed files with 11 additions and 3 deletions

View file

@ -88,7 +88,11 @@
<Grid x:Name="BG"> <Grid x:Name="BG">
<Border x:Name="Content" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,1,0,0"> <Border x:Name="Content" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,1,0,0">
<StackPanel Orientation="Horizontal" Margin="4,0" MaxWidth="300"> <StackPanel Orientation="Horizontal" Margin="4,0" MaxWidth="300">
<TextBlock Text="{Binding Line.CommitSHA}" Foreground="#FFFFB835"/> <TextBlock>
<Hyperlink NavigateUri="{Binding Line.CommitSHA}" RequestNavigate="GotoCommit" Foreground="DarkOrange" ToolTip="GOTO COMMIT">
<Run Text="{Binding Line.CommitSHA, Mode=OneWay}"/>
</Hyperlink>
</TextBlock>
<TextBlock Text="{Binding Line.Time}" Margin="8,0"/> <TextBlock Text="{Binding Line.Time}" Margin="8,0"/>
<TextBlock Text="{Binding Line.Author}" Foreground="#FFFFB835"/> <TextBlock Text="{Binding Line.Author}" Foreground="#FFFFB835"/>
</StackPanel> </StackPanel>

View file

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Navigation;
namespace SourceGit.Views { namespace SourceGit.Views {
/// <summary> /// <summary>
@ -156,12 +157,15 @@ namespace SourceGit.Views {
var r = blame.SelectedItem as Record; var r = blame.SelectedItem as Record;
if (r == null) return; if (r == null) return;
Models.Watcher.Get(repo).NavigateTo(r.Line.CommitSHA);
foreach (var one in Records) { foreach (var one in Records) {
one.IsSelected = one.Line.CommitSHA == r.Line.CommitSHA; one.IsSelected = one.Line.CommitSHA == r.Line.CommitSHA;
} }
} }
private void GotoCommit(object sender, RequestNavigateEventArgs e) {
Models.Watcher.Get(repo).NavigateTo(e.Uri.OriginalString);
e.Handled = true;
}
#endregion #endregion
private string repo = null; private string repo = null;