@@ -12,7 +12,7 @@ import { Emitter } from '../../../../../base/common/event.js';
12
12
import { Iterable } from '../../../../../base/common/iterator.js' ;
13
13
import { Disposable , DisposableStore , dispose } from '../../../../../base/common/lifecycle.js' ;
14
14
import { ResourceMap } from '../../../../../base/common/map.js' ;
15
- import { asyncTransaction , autorun , derived , derivedOpts , IObservable , IReader , ITransaction , ObservablePromise , observableValue , transaction } from '../../../../../base/common/observable.js' ;
15
+ import { autorun , derived , derivedOpts , IObservable , IReader , ITransaction , ObservablePromise , observableValue , transaction } from '../../../../../base/common/observable.js' ;
16
16
import { isEqual } from '../../../../../base/common/resources.js' ;
17
17
import { URI } from '../../../../../base/common/uri.js' ;
18
18
import { IBulkEditService } from '../../../../../editor/browser/services/bulkEditService.js' ;
@@ -224,9 +224,9 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
224
224
for ( const [ uri , content ] of restoredSessionState . initialFileContents ) {
225
225
this . _initialFileContents . set ( uri , content ) ;
226
226
}
227
- await asyncTransaction ( async tx => {
228
- this . _pendingSnapshot = restoredSessionState . pendingSnapshot ;
229
- await this . _restoreSnapshot ( restoredSessionState . recentSnapshot , tx , false ) ;
227
+ this . _pendingSnapshot = restoredSessionState . pendingSnapshot ;
228
+ await this . _restoreSnapshot ( restoredSessionState . recentSnapshot , false ) ;
229
+ transaction ( async tx => {
230
230
this . _linearHistory . set ( restoredSessionState . linearHistory , tx ) ;
231
231
this . _linearHistoryIndex . set ( restoredSessionState . linearHistoryIndex , tx ) ;
232
232
this . _state . set ( ChatEditingSessionState . Idle , tx ) ;
@@ -491,10 +491,8 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
491
491
const stopRef = this . _findEditStop ( requestId , stopId ) ;
492
492
if ( stopRef ) {
493
493
this . _ensurePendingSnapshot ( ) ;
494
- await asyncTransaction ( async tx => {
495
- this . _linearHistoryIndex . set ( stopRef . historyIndex , tx ) ;
496
- await this . _restoreSnapshot ( stopRef . stop , tx ) ;
497
- } ) ;
494
+ this . _linearHistoryIndex . set ( stopRef . historyIndex , undefined ) ;
495
+ await this . _restoreSnapshot ( stopRef . stop ) ;
498
496
this . _updateRequestHiddenState ( ) ;
499
497
}
500
498
} else {
@@ -507,7 +505,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
507
505
}
508
506
}
509
507
510
- private async _restoreSnapshot ( { entries } : IChatEditingSessionStop , tx : ITransaction | undefined , restoreResolvedToDisk = true ) : Promise < void > {
508
+ private async _restoreSnapshot ( { entries } : IChatEditingSessionStop , restoreResolvedToDisk = true ) : Promise < void > {
511
509
512
510
// Reset all the files which are modified in this session state
513
511
// but which are not found in the snapshot
@@ -528,7 +526,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
528
526
entriesArr . push ( entry ) ;
529
527
}
530
528
531
- this . _entriesObs . set ( entriesArr , tx ) ;
529
+ this . _entriesObs . set ( entriesArr , undefined ) ;
532
530
}
533
531
534
532
remove ( ...uris : URI [ ] ) : void {
@@ -562,37 +560,32 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
562
560
async accept ( ...uris : URI [ ] ) : Promise < void > {
563
561
this . _assertNotDisposed ( ) ;
564
562
565
- await asyncTransaction ( async tx => {
566
-
567
- if ( uris . length === 0 ) {
568
- await Promise . all ( this . _entriesObs . get ( ) . map ( entry => entry . accept ( tx ) ) ) ;
569
- }
563
+ if ( uris . length === 0 ) {
564
+ await Promise . all ( this . _entriesObs . get ( ) . map ( entry => entry . accept ( ) ) ) ;
565
+ }
570
566
571
- for ( const uri of uris ) {
572
- const entry = this . _entriesObs . get ( ) . find ( e => isEqual ( e . modifiedURI , uri ) ) ;
573
- if ( entry ) {
574
- await entry . accept ( tx ) ;
575
- }
567
+ for ( const uri of uris ) {
568
+ const entry = this . _entriesObs . get ( ) . find ( e => isEqual ( e . modifiedURI , uri ) ) ;
569
+ if ( entry ) {
570
+ await entry . accept ( ) ;
576
571
}
577
- } ) ;
572
+ }
578
573
this . _accessibilitySignalService . playSignal ( AccessibilitySignal . editsKept , { allowManyInParallel : true } ) ;
579
574
}
580
575
581
576
async reject ( ...uris : URI [ ] ) : Promise < void > {
582
577
this . _assertNotDisposed ( ) ;
583
578
584
- await asyncTransaction ( async tx => {
585
- if ( uris . length === 0 ) {
586
- await Promise . all ( this . _entriesObs . get ( ) . map ( entry => entry . reject ( tx ) ) ) ;
587
- }
579
+ if ( uris . length === 0 ) {
580
+ await Promise . all ( this . _entriesObs . get ( ) . map ( entry => entry . reject ( ) ) ) ;
581
+ }
588
582
589
- for ( const uri of uris ) {
590
- const entry = this . _entriesObs . get ( ) . find ( e => isEqual ( e . modifiedURI , uri ) ) ;
591
- if ( entry ) {
592
- await entry . reject ( tx ) ;
593
- }
583
+ for ( const uri of uris ) {
584
+ const entry = this . _entriesObs . get ( ) . find ( e => isEqual ( e . modifiedURI , uri ) ) ;
585
+ if ( entry ) {
586
+ await entry . reject ( ) ;
594
587
}
595
- } ) ;
588
+ }
596
589
this . _accessibilitySignalService . playSignal ( AccessibilitySignal . editsUndone , { allowManyInParallel : true } ) ;
597
590
}
598
591
@@ -738,10 +731,8 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
738
731
}
739
732
740
733
this . _ensurePendingSnapshot ( ) ;
741
- await asyncTransaction ( async tx => {
742
- await this . _restoreSnapshot ( previousSnapshot . stop , tx ) ;
743
- this . _linearHistoryIndex . set ( newIndex , tx ) ;
744
- } ) ;
734
+ await this . _restoreSnapshot ( previousSnapshot . stop ) ;
735
+ this . _linearHistoryIndex . set ( newIndex , undefined ) ;
745
736
this . _updateRequestHiddenState ( ) ;
746
737
}
747
738
@@ -756,10 +747,8 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
756
747
if ( ! nextSnapshot ) {
757
748
return ;
758
749
}
759
- await asyncTransaction ( async tx => {
760
- await this . _restoreSnapshot ( nextSnapshot , tx ) ;
761
- this . _linearHistoryIndex . set ( newIndex , tx ) ;
762
- } ) ;
750
+ await this . _restoreSnapshot ( nextSnapshot ) ;
751
+ this . _linearHistoryIndex . set ( newIndex , undefined ) ;
763
752
this . _updateRequestHiddenState ( ) ;
764
753
}
765
754
@@ -809,7 +798,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
809
798
*
810
799
* @param next If true, this will edit the snapshot _after_ the undo stop
811
800
*/
812
- private ensureEditInUndoStopMatches ( requestId : string , undoStop : string | undefined , entry : AbstractChatEditingModifiedFileEntry , next : boolean , tx : ITransaction ) {
801
+ private ensureEditInUndoStopMatches ( requestId : string , undoStop : string | undefined , entry : AbstractChatEditingModifiedFileEntry , next : boolean , tx : ITransaction | undefined ) {
813
802
const history = this . _linearHistory . get ( ) ;
814
803
const snapIndex = history . findIndex ( s => s . requestId === requestId ) ;
815
804
if ( snapIndex === - 1 ) {
@@ -871,20 +860,19 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
871
860
}
872
861
873
862
private async _resolve ( requestId : string , undoStop : string | undefined , resource : URI ) : Promise < void > {
874
- await asyncTransaction ( async ( tx ) => {
875
- const hasOtherTasks = Iterable . some ( this . _streamingEditLocks . keys ( ) , k => k !== resource . toString ( ) ) ;
876
- if ( ! hasOtherTasks ) {
877
- this . _state . set ( ChatEditingSessionState . Idle , tx ) ;
878
- }
879
863
880
- const entry = this . _getEntry ( resource ) ;
881
- if ( ! entry ) {
882
- return ;
883
- }
864
+ const hasOtherTasks = Iterable . some ( this . _streamingEditLocks . keys ( ) , k => k !== resource . toString ( ) ) ;
865
+ if ( ! hasOtherTasks ) {
866
+ this . _state . set ( ChatEditingSessionState . Idle , undefined ) ;
867
+ }
884
868
885
- this . ensureEditInUndoStopMatches ( requestId , undoStop , entry , /* next= */ true , tx ) ;
886
- return entry . acceptStreamingEditsEnd ( tx ) ;
887
- } ) ;
869
+ const entry = this . _getEntry ( resource ) ;
870
+ if ( ! entry ) {
871
+ return ;
872
+ }
873
+
874
+ this . ensureEditInUndoStopMatches ( requestId , undoStop , entry , /* next= */ true , undefined ) ;
875
+ return entry . acceptStreamingEditsEnd ( ) ;
888
876
889
877
}
890
878
0 commit comments