Skip to content

Commit

Permalink
Insert artificial commits if filter without any matches is applied
Browse files Browse the repository at this point in the history
Handle selection after refresh if artificial commits are
removed from the view
  • Loading branch information
gerhardol committed Aug 22, 2022
1 parent 915cb47 commit 2b19a57
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions GitUI/UserControls/RevisionGrid/RevisionGridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,13 +1192,14 @@ bool ShowArtificialRevisions()
&& !Module.IsBareRepository();
}

bool AddArtificialRevisions(bool insertWithMatch = false, IEnumerable<ObjectId> headParents = null)
bool AddArtificialRevisions(IEnumerable<ObjectId> headParents = null)
{
if (!ShowArtificialRevisions())
{
return false;
}

bool insertWithMatch = headParents is not null;
var userName = Module.GetEffectiveSetting(SettingKeyString.UserName);
var userEmail = Module.GetEffectiveSetting(SettingKeyString.UserEmail);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1291,7 +1292,7 @@ void OnRevisionReadCompleted()
IEnumerable<ObjectId> headParents = null;
bool refresh = false;
if (firstRevisionReceived && !headIsHandled && ShowArtificialRevisions())
if (!headIsHandled && ShowArtificialRevisions())
{
if (CurrentCheckout is not null)
{
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 2b19a57

Please sign in to comment.