From a980cc987d60c038e0ce92eee8fb972fb4737ac6 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 21 Nov 2024 09:57:43 +0800 Subject: [PATCH] fix: wired ordering when cherry-pick multiple commits (#726) Since the items in `ListBox.SelectedItems` are not ordered by their position in the list, but in the order user selected, it need be sorted before `cherry-pick` Signed-off-by: leo --- src/ViewModels/Histories.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 55b04713..2f597849 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -243,6 +243,12 @@ namespace SourceGit.ViewModels if (canCherryPick) { + // Sort selected commits in order. + selected.Sort((l, r) => + { + return _commits.IndexOf(r) - _commits.IndexOf(l); + }); + var cherryPickMultiple = new MenuItem(); cherryPickMultiple.Header = App.Text("CommitCM.CherryPickMultiple"); cherryPickMultiple.Icon = App.CreateMenuIcon("Icons.CherryPick");