From 2e60c98eee723855d74dbef2a161dfbee3752e53 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Tue, 30 Apr 2024 21:22:48 +0800 Subject: [PATCH] fix: keep selected commit after _commits var reassigned --- src/ViewModels/Histories.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 652ba805..fe02ce23 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -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(() => {