@@ -1387,47 +1387,62 @@ export class Repository implements Disposable {
1387
1387
}
1388
1388
1389
1389
async clean ( resources : Uri [ ] ) : Promise < void > {
1390
- await this . run ( Operation . Clean , async ( ) => {
1391
- const toClean : string [ ] = [ ] ;
1392
- const toCheckout : string [ ] = [ ] ;
1393
- const submodulesToUpdate : string [ ] = [ ] ;
1394
- const resourceStates = [ ...this . workingTreeGroup . resourceStates , ...this . untrackedGroup . resourceStates ] ;
1395
-
1396
- resources . forEach ( r => {
1397
- const fsPath = r . fsPath ;
1398
-
1399
- for ( const submodule of this . submodules ) {
1400
- if ( path . join ( this . root , submodule . path ) === fsPath ) {
1401
- submodulesToUpdate . push ( fsPath ) ;
1390
+ await this . run (
1391
+ Operation . Clean ,
1392
+ async ( ) => {
1393
+ const toClean : string [ ] = [ ] ;
1394
+ const toCheckout : string [ ] = [ ] ;
1395
+ const submodulesToUpdate : string [ ] = [ ] ;
1396
+ const resourceStates = [ ...this . workingTreeGroup . resourceStates , ...this . untrackedGroup . resourceStates ] ;
1397
+
1398
+ resources . forEach ( r => {
1399
+ const fsPath = r . fsPath ;
1400
+
1401
+ for ( const submodule of this . submodules ) {
1402
+ if ( path . join ( this . root , submodule . path ) === fsPath ) {
1403
+ submodulesToUpdate . push ( fsPath ) ;
1404
+ return ;
1405
+ }
1406
+ }
1407
+
1408
+ const raw = r . toString ( ) ;
1409
+ const scmResource = find ( resourceStates , sr => sr . resourceUri . toString ( ) === raw ) ;
1410
+
1411
+ if ( ! scmResource ) {
1402
1412
return ;
1403
1413
}
1404
- }
1405
1414
1406
- const raw = r . toString ( ) ;
1407
- const scmResource = find ( resourceStates , sr => sr . resourceUri . toString ( ) === raw ) ;
1415
+ switch ( scmResource . type ) {
1416
+ case Status . UNTRACKED :
1417
+ case Status . IGNORED :
1418
+ toClean . push ( fsPath ) ;
1419
+ break ;
1408
1420
1409
- if ( ! scmResource ) {
1410
- return ;
1411
- }
1421
+ default :
1422
+ toCheckout . push ( fsPath ) ;
1423
+ break ;
1424
+ }
1425
+ } ) ;
1412
1426
1413
- switch ( scmResource . type ) {
1414
- case Status . UNTRACKED :
1415
- case Status . IGNORED :
1416
- toClean . push ( fsPath ) ;
1417
- break ;
1427
+ await this . repository . clean ( toClean ) ;
1428
+ await this . repository . checkout ( '' , toCheckout ) ;
1429
+ await this . repository . updateSubmodules ( submodulesToUpdate ) ;
1418
1430
1419
- default :
1420
- toCheckout . push ( fsPath ) ;
1421
- break ;
1422
- }
1423
- } ) ;
1431
+ this . closeDiffEditors ( [ ] , [ ...toClean , ...toCheckout ] ) ;
1432
+ } ,
1433
+ ( ) => {
1434
+ const resourcePaths = resources . map ( r => r . fsPath ) ;
1435
+
1436
+ // Remove resource(s) from working group
1437
+ const workingTreeGroup = this . workingTreeGroup . resourceStates
1438
+ . filter ( r => ! resourcePaths . includes ( r . resourceUri . fsPath ) ) ;
1424
1439
1425
- await this . repository . clean ( toClean ) ;
1426
- await this . repository . checkout ( '' , toCheckout ) ;
1427
- await this . repository . updateSubmodules ( submodulesToUpdate ) ;
1440
+ // Remove resource(s) from untracked group
1441
+ const untrackedGroup = this . untrackedGroup . resourceStates
1442
+ . filter ( r => ! resourcePaths . includes ( r . resourceUri . fsPath ) ) ;
1428
1443
1429
- this . closeDiffEditors ( [ ] , [ ... toClean , ... toCheckout ] ) ;
1430
- } ) ;
1444
+ return { workingTreeGroup , untrackedGroup } ;
1445
+ } ) ;
1431
1446
}
1432
1447
1433
1448
closeDiffEditors ( indexResources : string [ ] | undefined , workingTreeResources : string [ ] | undefined , ignoreSetting : boolean = false ) : void {
0 commit comments