From fa7c021a82036a3ecc3a3e6aa70c41e499b8e954 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:54:39 +0100 Subject: [PATCH] SCM - fix treeview comparison function (#203325) --- .../contrib/scm/browser/scmViewPane.ts | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index 562bc927780..336f381c964 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -1171,28 +1171,16 @@ export class SCMTreeSorter implements ITreeSorter { return 1; } - if (isSCMViewSeparator(one)) { - if (!isSCMHistoryItemGroupTreeElement(other) && !isSCMResourceGroup(other)) { - throw new Error('Invalid comparison'); - } - - return 0; + if (isSCMResourceGroup(one)) { + return isSCMResourceGroup(other) ? 0 : -1; } - if (isSCMResourceGroup(one)) { - if (!isSCMResourceGroup(other)) { - throw new Error('Invalid comparison'); - } - - return 0; + if (isSCMViewSeparator(one)) { + return isSCMResourceGroup(other) ? 1 : -1; } if (isSCMHistoryItemGroupTreeElement(one)) { - if (!isSCMHistoryItemGroupTreeElement(other) && !isSCMResourceGroup(other) && !isSCMViewSeparator(other)) { - throw new Error('Invalid comparison'); - } - - return 0; + return isSCMHistoryItemGroupTreeElement(other) ? 0 : 1; } if (isSCMHistoryItemTreeElement(one)) {