diff --git a/GitUI/UserControls/RevisionGrid/AuthorRevisionHighlighting.cs b/GitUI/UserControls/RevisionGrid/AuthorRevisionHighlighting.cs
index a9eebe0c134..acb3feb85b2 100644
--- a/GitUI/UserControls/RevisionGrid/AuthorRevisionHighlighting.cs
+++ b/GitUI/UserControls/RevisionGrid/AuthorRevisionHighlighting.cs
@@ -3,6 +3,7 @@
using System.Linq;
using GitCommands;
using GitCommands.Config;
+using GitUIPluginInterfaces;
using JetBrains.Annotations;
namespace GitUI.UserControls
@@ -14,7 +15,7 @@ internal sealed class AuthorRevisionHighlighting
/// true if the UI should be refreshed in response to this change.
[MustUseReturnValue]
- public bool ProcessRevisionSelectionChange(GitModule currentModule, IReadOnlyCollection selectedRevisions)
+ public bool ProcessRevisionSelectionChange(IGitModule currentModule, IReadOnlyCollection selectedRevisions)
{
if (selectedRevisions.Count > 1)
{
@@ -24,7 +25,6 @@ public bool ProcessRevisionSelectionChange(GitModule currentModule, IReadOnlyCol
var revision = selectedRevisions.FirstOrDefault();
var changed = !string.Equals(revision?.AuthorEmail, AuthorEmailToHighlight, StringComparison.OrdinalIgnoreCase);
-
if (changed)
{
AuthorEmailToHighlight = revision != null
@@ -38,6 +38,11 @@ public bool ProcessRevisionSelectionChange(GitModule currentModule, IReadOnlyCol
public bool IsHighlighted([CanBeNull] GitRevision revision)
{
+ if (string.IsNullOrWhiteSpace(revision?.AuthorEmail))
+ {
+ return false;
+ }
+
return string.Equals(revision?.AuthorEmail, AuthorEmailToHighlight, StringComparison.OrdinalIgnoreCase);
}
}
diff --git a/GitUI/UserControls/RevisionGrid/RevisionDataGridView.cs b/GitUI/UserControls/RevisionGrid/RevisionDataGridView.cs
index 08a9889049f..d25b1d9b71f 100644
--- a/GitUI/UserControls/RevisionGrid/RevisionDataGridView.cs
+++ b/GitUI/UserControls/RevisionGrid/RevisionDataGridView.cs
@@ -119,7 +119,7 @@ void OnRowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
e.RowBounds.Height > 0)
{
// Draw row background
- var backBrush = GetBackground(e.State, e.RowIndex);
+ var backBrush = GetBackground(e.State, e.RowIndex, null);
e.Graphics.FillRectangle(backBrush, e.RowBounds);
}
}
@@ -176,6 +176,8 @@ internal Font NormalFont
}
}
+ internal AuthorRevisionHighlighting AuthorHighlighting { get; set; }
+
// Contains the object Id's that will be selected as soon as they are loaded.
public HashSet ToBeSelectedObjectIds { get; set; } = new HashSet();
@@ -238,19 +240,24 @@ private Color GetForeground(DataGridViewElementStates state, int rowIndex)
: Color.Black;
}
- private static Brush GetBackground(DataGridViewElementStates state, int rowIndex)
+ private Brush GetBackground(DataGridViewElementStates state, int rowIndex, GitRevision revision)
{
if (state.HasFlag(DataGridViewElementStates.Selected))
{
return SystemBrushes.Highlight;
}
+ if (revision != null && !revision.IsArtificial && AuthorHighlighting.IsHighlighted(revision))
+ {
+ return Brushes.LightYellow;
+ }
+
if (rowIndex % 2 == 0 && AppSettings.RevisionGraphDrawAlternateBackColor)
{
return _alternatingRowBackgroundBrush;
}
- return Brushes.White;
+ return SystemBrushes.Window;
}
private void OnCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
@@ -269,9 +276,10 @@ private void OnCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
if (Columns[e.ColumnIndex].Tag is ColumnProvider provider)
{
- var backBrush = GetBackground(e.State, e.RowIndex);
+ var backBrush = GetBackground(e.State, e.RowIndex, revision);
var foreColor = GetForeground(e.State, e.RowIndex);
+ e.Graphics.FillRectangle(backBrush, e.CellBounds);
provider.OnCellPainting(e, revision, _rowHeight, new CellStyle(backBrush, foreColor, _normalFont, _boldFont, _monospaceFont));
e.Handled = true;
diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
index ef6cf567285..95a669ae782 100644
--- a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
+++ b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
@@ -185,6 +185,7 @@ public RevisionGridControl()
HotkeysEnabled = true;
_gridView.ShowCellToolTips = false;
+ _gridView.AuthorHighlighting = _authorHighlighting;
_gridView.KeyPress += (_, e) => _quickSearchProvider.OnKeyPress(e);
_gridView.KeyUp += OnGridViewKeyUp;
@@ -994,9 +995,12 @@ void OnRevisionReadCompleted()
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
{
await this.SwitchToMainThreadAsync();
+
SetPage(_gridView);
_isRefreshingRevisions = false;
CheckAndRepairInitialRevision();
+ HighlightRevisionsByAuthor(GetSelectedRevisions());
+
if (ShowBuildServerInfo)
{
await _buildServerWatcher.LaunchBuildServerInfoFetchOperationAsync();
@@ -1188,6 +1192,11 @@ private void OnGridViewSelectionChanged(object sender, EventArgs e)
compareWithCurrentBranchToolStripMenuItem.Enabled = Module.GetSelectedBranch(setDefaultIfEmpty: false).IsNotNullOrWhitespace();
compareSelectedCommitsMenuItem.Enabled = firstSelectedRevision != null && secondSelectedRevision != null;
+ HighlightRevisionsByAuthor(selectedRevisions);
+ }
+
+ private void HighlightRevisionsByAuthor(in IReadOnlyList selectedRevisions)
+ {
if (Parent != null &&
!_gridView.UpdatingVisibleRows &&
_authorHighlighting.ProcessRevisionSelectionChange(Module, selectedRevisions))