@@ -12,7 +12,7 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
12
12
import { WorkingCopyHistoryTracker } from 'vs/workbench/services/workingCopy/common/workingCopyHistoryTracker' ;
13
13
import { Disposable } from 'vs/base/common/lifecycle' ;
14
14
import { IWorkingCopyHistoryEntry , IWorkingCopyHistoryEntryDescriptor , IWorkingCopyHistoryEvent , IWorkingCopyHistoryService , MAX_PARALLEL_HISTORY_IO_OPS } from 'vs/workbench/services/workingCopy/common/workingCopyHistory' ;
15
- import { FileOperation , FileOperationError , FileOperationEvent , FileOperationResult , IFileService , IFileStatWithMetadata } from 'vs/platform/files/common/files' ;
15
+ import { FileOperationError , FileOperationResult , IFileService , IFileStatWithMetadata } from 'vs/platform/files/common/files' ;
16
16
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService' ;
17
17
import { URI } from 'vs/base/common/uri' ;
18
18
import { DeferredPromise , Limiter } from 'vs/base/common/async' ;
@@ -525,8 +525,6 @@ export abstract class WorkingCopyHistoryService extends Disposable implements IW
525
525
super ( ) ;
526
526
527
527
this . resolveLocalHistoryHome ( ) ;
528
-
529
- this . _register ( this . fileService . onDidRunOperation ( e => this . onDidRunFileOperation ( e ) ) ) ;
530
528
}
531
529
532
530
private async resolveLocalHistoryHome ( ) : Promise < void > {
@@ -550,26 +548,18 @@ export abstract class WorkingCopyHistoryService extends Disposable implements IW
550
548
this . localHistoryHome . complete ( historyHome ) ;
551
549
}
552
550
553
- private async onDidRunFileOperation ( e : FileOperationEvent ) : Promise < void > {
554
- if ( ! e . isOperation ( FileOperation . MOVE ) ) {
555
- return ; // only interested in move operations
556
- }
557
-
558
- const source = e . resource ;
559
- const target = e . target . resource ;
560
-
561
- const limiter = new Limiter ( MAX_PARALLEL_HISTORY_IO_OPS ) ;
562
- const promises = [ ] ;
551
+ async moveEntries ( source : URI , target : URI ) : Promise < URI [ ] > {
552
+ const limiter = new Limiter < URI > ( MAX_PARALLEL_HISTORY_IO_OPS ) ;
553
+ const promises : Promise < URI > [ ] = [ ] ;
563
554
564
555
for ( const [ resource , model ] of this . models ) {
565
556
if ( ! this . uriIdentityService . extUri . isEqualOrParent ( resource , source ) ) {
566
557
continue ; // model does not match moved resource
567
558
}
568
559
569
-
570
560
// Determine new resulting target resource
571
561
let targetResource : URI ;
572
- if ( isEqual ( source , resource ) ) {
562
+ if ( this . uriIdentityService . extUri . isEqual ( source , resource ) ) {
573
563
targetResource = target ; // file got moved
574
564
} else {
575
565
const index = indexOfPath ( resource . path , source . path ) ;
@@ -578,35 +568,39 @@ export abstract class WorkingCopyHistoryService extends Disposable implements IW
578
568
579
569
// Figure out save source
580
570
let saveSource : SaveSource ;
581
- if ( isEqual ( dirname ( resource ) , dirname ( targetResource ) ) ) {
571
+ if ( this . uriIdentityService . extUri . isEqual ( dirname ( resource ) , dirname ( targetResource ) ) ) {
582
572
saveSource = WorkingCopyHistoryService . FILE_RENAMED_SOURCE ;
583
573
} else {
584
574
saveSource = WorkingCopyHistoryService . FILE_MOVED_SOURCE ;
585
575
}
586
576
587
577
// Move entries to target queued
588
- promises . push ( limiter . queue ( ( ) => this . moveEntries ( model , saveSource , resource , targetResource ) ) ) ;
578
+ promises . push ( limiter . queue ( ( ) => this . doMoveEntries ( model , saveSource , resource , targetResource ) ) ) ;
589
579
}
590
580
591
581
if ( ! promises . length ) {
592
- return ;
582
+ return [ ] ;
593
583
}
594
584
595
585
// Await move operations
596
- await Promise . all ( promises ) ;
586
+ const resources = await Promise . all ( promises ) ;
597
587
598
588
// Events
599
589
this . _onDidMoveEntries . fire ( ) ;
590
+
591
+ return resources ;
600
592
}
601
593
602
- private async moveEntries ( model : WorkingCopyHistoryModel , source : SaveSource , sourceWorkingCopyResource : URI , targetWorkingCopyResource : URI ) : Promise < void > {
594
+ private async doMoveEntries ( model : WorkingCopyHistoryModel , source : SaveSource , sourceWorkingCopyResource : URI , targetWorkingCopyResource : URI ) : Promise < URI > {
603
595
604
596
// Move to target via model
605
597
await model . moveEntries ( targetWorkingCopyResource , source , CancellationToken . None ) ;
606
598
607
599
// Update model in our map
608
600
this . models . delete ( sourceWorkingCopyResource ) ;
609
601
this . models . set ( targetWorkingCopyResource , model ) ;
602
+
603
+ return targetWorkingCopyResource ;
610
604
}
611
605
612
606
async addEntry ( { resource, source, timestamp } : IWorkingCopyHistoryEntryDescriptor , token : CancellationToken ) : Promise < IWorkingCopyHistoryEntry | undefined > {
0 commit comments