Merge pull request #104 from gadfly3173/fix/keep-commit

fix: keep selected commit after _commits var reassigned
This commit is contained in:
leo 2024-05-03 21:07:49 +08:00 committed by GitHub
commit 63248dafb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,8 +34,19 @@ namespace SourceGit.ViewModels
get => _commits;
set
{
var oldAutoSelectedCommitSHA = AutoSelectedCommit?.SHA;
if (SetProperty(ref _commits, value))
{
Models.Commit newSelectedCommit = null;
if (value.Count > 0 && oldAutoSelectedCommitSHA != null)
{
newSelectedCommit = value.Find(x => x.SHA == oldAutoSelectedCommitSHA);
}
if (newSelectedCommit != AutoSelectedCommit)
{
AutoSelectedCommit = newSelectedCommit;
}
Graph = null;
Task.Run(() =>
{