@@ -22,7 +22,7 @@ import { IPushErrorHandlerRegistry } from './pushError';
22
22
import { IRemoteSourcePublisherRegistry } from './remotePublisher' ;
23
23
import { StatusBarCommands } from './statusbar' ;
24
24
import { toGitUri } from './uri' ;
25
- import { anyEvent , combinedDisposable , debounceEvent , dispose , EmptyDisposable , eventToPromise , filterEvent , find , getCommitShortHash , IDisposable , isDescendant , isLinuxSnap , isRemote , Limiter , onceEvent , pathEquals , relativePath } from './util' ;
25
+ import { anyEvent , combinedDisposable , debounceEvent , dispose , EmptyDisposable , eventToPromise , filterEvent , find , getCommitShortHash , IDisposable , isDescendant , isLinuxSnap , isRemote , isWindows , Limiter , onceEvent , pathEquals , relativePath } from './util' ;
26
26
import { IFileWatcher , watch } from './watch' ;
27
27
import { ISourceControlHistoryItemDetailsProviderRegistry } from './historyItemDetailsProvider' ;
28
28
@@ -1397,9 +1397,29 @@ export class Repository implements Disposable {
1397
1397
1398
1398
if ( toClean . length > 0 ) {
1399
1399
if ( discardUntrackedChangesToTrash ) {
1400
- const limiter = new Limiter < void > ( 5 ) ;
1401
- await Promise . all ( toClean . map ( fsPath => limiter . queue (
1402
- async ( ) => await workspace . fs . delete ( Uri . file ( fsPath ) , { useTrash : true } ) ) ) ) ;
1400
+ try {
1401
+ // Attempt to move the first resource to the recycle bin/trash to check
1402
+ // if it is supported. If it fails, we show a confirmation dialog and
1403
+ // fall back to deletion.
1404
+ await workspace . fs . delete ( Uri . file ( toClean [ 0 ] ) , { useTrash : true } ) ;
1405
+
1406
+ const limiter = new Limiter < void > ( 5 ) ;
1407
+ await Promise . all ( toClean . slice ( 1 ) . map ( fsPath => limiter . queue (
1408
+ async ( ) => await workspace . fs . delete ( Uri . file ( fsPath ) , { useTrash : true } ) ) ) ) ;
1409
+ } catch {
1410
+ const message = isWindows
1411
+ ? l10n . t ( 'Failed to delete using the Recycle Bin. Do you want to permanently delete instead?' )
1412
+ : l10n . t ( 'Failed to delete using the Trash. Do you want to permanently delete instead?' ) ;
1413
+ const primaryAction = toClean . length === 1
1414
+ ? l10n . t ( 'Delete File' )
1415
+ : l10n . t ( 'Delete All {0} Files' , resources . length ) ;
1416
+
1417
+ const result = await window . showWarningMessage ( message , { modal : true } , primaryAction ) ;
1418
+ if ( result === primaryAction ) {
1419
+ // Delete permanently
1420
+ await this . repository . clean ( toClean ) ;
1421
+ }
1422
+ }
1403
1423
} else {
1404
1424
await this . repository . clean ( toClean ) ;
1405
1425
}
0 commit comments