From 25b7a17c23c0abf83a2d0243c3b59026dca525a0 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] 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs index 44e62fdc61f..b4d30d14ef3 100644 --- a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs +++ b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs @@ -1258,7 +1258,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 +1291,7 @@ void OnRevisionReadCompleted() IEnumerable headParents = null; bool refresh = false; - if (firstRevisionReceived && !headIsHandled && ShowArtificialRevisions()) + if (!headIsHandled && ShowArtificialRevisions()) { if (CurrentCheckout is not null) { @@ -1324,7 +1324,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