Git - Remove duplicate resources to have the correct resource count in the discard dialog (#169258)

Remove duplicate resources to have the correct resource count in the discard dialog
This commit is contained in:
Ladislau Szomoru
2022-12-15 15:29:25 +01:00
committed by GitHub
parent 3d58b4623b
commit 07b7ca6402

View File

@@ -1399,7 +1399,20 @@ export class CommandCenter {
@command('git.clean')
async clean(...resourceStates: SourceControlResourceState[]): Promise<void> {
resourceStates = resourceStates.filter(s => !!s);
// Remove duplicate resources
const resourceUris = new Set<string>();
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();