From 2b19a5707ca76a321d41a7930faeab50a6d9484a Mon Sep 17 00:00:00 2001 From: Gerhard Olsson <6248932+gerhardol@users.noreply.github.com> Date: Mon, 22 Aug 2022 21:08:00 +0200 Subject: [PATCH 1/2] Insert artificial commits if filter without any matches is applied Handle selection after refresh if artificial commits are removed from the view --- .../RevisionGrid/RevisionGridControl.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs index 44e62fdc61f..d83a339c326 100644 --- a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs +++ b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs @@ -1192,13 +1192,14 @@ bool ShowArtificialRevisions() && !Module.IsBareRepository(); } - bool AddArtificialRevisions(bool insertWithMatch = false, IEnumerable headParents = null) + bool AddArtificialRevisions(IEnumerable headParents = null) { if (!ShowArtificialRevisions()) { return false; } + bool insertWithMatch = headParents is not null; var userName = Module.GetEffectiveSetting(SettingKeyString.UserName); var userEmail = Module.GetEffectiveSetting(SettingKeyString.UserEmail); @@ -1258,7 +1259,7 @@ void OnRevisionReadCompleted() { await TaskScheduler.Default; - // No revisions at all received + // No revisions at all received without any filter await semaphoreUpdateGrid.WaitAsync(cancellationToken); bool showArtificial = AddArtificialRevisions(); @@ -1291,7 +1292,7 @@ void OnRevisionReadCompleted() IEnumerable headParents = null; bool refresh = false; - if (firstRevisionReceived && !headIsHandled && ShowArtificialRevisions()) + if (!headIsHandled && ShowArtificialRevisions()) { if (CurrentCheckout is not null) { @@ -1301,7 +1302,7 @@ void OnRevisionReadCompleted() // If parents are rewritten HEAD may not be included // Insert the artificial commits where relevant if possible, otherwise first - refresh = AddArtificialRevisions(insertWithMatch: true, headParents); + refresh = AddArtificialRevisions(headParents); } // All revisions are loaded (but maybe not yet the grid) @@ -1324,7 +1325,17 @@ void OnRevisionReadCompleted() } else { - parents = TryGetParents(Module, _filterInfo, notSelectedId); + if (notSelectedId.IsArtificial) + { + notSelectedId = CurrentCheckout is not null + ? CurrentCheckout + : _gridView.ToBeSelectedObjectIds.Where(id => !id.IsArtificial).FirstOrDefault(); + } + + if (notSelectedId is not null) + { + parents = TryGetParents(Module, _filterInfo, notSelectedId); + } } // Try to select the first of the parents From b4d1c455dda4e69b639d9c61c9d3de8304784c61 Mon Sep 17 00:00:00 2001 From: Gerhard Olsson <6248932+gerhardol@users.noreply.github.com> Date: Fri, 26 Aug 2022 00:13:43 +0200 Subject: [PATCH 2/2] fixup! Insert artificial commits if filter without any matches is applied Handle selection after refresh if artificial commits are removed from the view --- .../RevisionGrid/RevisionGridControl.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs index d83a339c326..bbda128534d 100644 --- a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs +++ b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs @@ -1323,19 +1323,10 @@ void OnRevisionReadCompleted() { parents = headParents.Skip(index + 1).ToList(); } - else + else if (!notSelectedId.IsArtificial) { - if (notSelectedId.IsArtificial) - { - notSelectedId = CurrentCheckout is not null - ? CurrentCheckout - : _gridView.ToBeSelectedObjectIds.Where(id => !id.IsArtificial).FirstOrDefault(); - } - - if (notSelectedId is not null) - { - parents = TryGetParents(Module, _filterInfo, notSelectedId); - } + // Ignore if the not selected is artificial, it is likely that the settings was changed + parents = TryGetParents(Module, _filterInfo, notSelectedId); } // Try to select the first of the parents