diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs index 417b816d..9f91205e 100644 --- a/src/ViewModels/FileHistories.cs +++ b/src/ViewModels/FileHistories.cs @@ -305,11 +305,23 @@ namespace SourceGit.ViewModels _repo.NavigateToCommit(commit.SHA); } + public string GetCommitFullMessage(Models.Commit commit) + { + var sha = commit.SHA; + if (_fullCommitMessages.TryGetValue(sha, out var msg)) + return msg; + + msg = new Commands.QueryCommitFullMessage(_repo.FullPath, sha).Result(); + _fullCommitMessages[sha] = msg; + return msg; + } + private readonly Repository _repo = null; private readonly string _file = null; private bool _isLoading = true; private bool _prevIsDiffMode = true; private List _commits = null; + private Dictionary _fullCommitMessages = new Dictionary(); private object _viewContent = null; } } diff --git a/src/Views/FileHistories.axaml b/src/Views/FileHistories.axaml index e33156fb..f597fc04 100644 --- a/src/Views/FileHistories.axaml +++ b/src/Views/FileHistories.axaml @@ -93,7 +93,12 @@ - + diff --git a/src/Views/FileHistories.axaml.cs b/src/Views/FileHistories.axaml.cs index be5affc3..a183182e 100644 --- a/src/Views/FileHistories.axaml.cs +++ b/src/Views/FileHistories.axaml.cs @@ -1,3 +1,5 @@ +using System; + using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; @@ -57,5 +59,22 @@ namespace SourceGit.Views e.Handled = true; } } + + private void OnCommitSubjectDataContextChanged(object sender, EventArgs e) + { + if (sender is TextBlock textBlock) + ToolTip.SetTip(textBlock, null); + } + + private void OnCommitSubjectPointerMoved(object sender, PointerEventArgs e) + { + if (sender is TextBlock { DataContext: Models.Commit commit } textBlock && + DataContext is ViewModels.FileHistories vm) + { + var tooltip = ToolTip.GetTip(textBlock); + if (tooltip == null) + ToolTip.SetTip(textBlock, vm.GetCommitFullMessage(commit)); + } + } } }