From b810b60cdeb6930afcdebb0f874ad3680d90d403 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Thu, 15 Dec 2022 15:04:02 +0100 Subject: [PATCH] Remove duplicate resources to have the correct resource count in the discard dialog --- extensions/git/src/commands.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 3c0eae6fd57b0..733e593733102 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1399,7 +1399,20 @@ export class CommandCenter { @command('git.clean') async clean(...resourceStates: SourceControlResourceState[]): Promise { - resourceStates = resourceStates.filter(s => !!s); + // Remove duplicate resources + const resourceUris = new Set(); + resourceStates = resourceStates.filter(s => { + if (s === undefined) { + return false; + } + + if (resourceUris.has(s.resourceUri.toString())) { + return false; + } + + resourceUris.add(s.resourceUri.toString()); + return true; + }); if (resourceStates.length === 0 || (resourceStates[0] && !(resourceStates[0].resourceUri instanceof Uri))) { const resource = this.getSCMResource();