@@ -33,7 +33,7 @@ import { IFileService } from '../../../../../platform/files/common/files.js';
33
33
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js' ;
34
34
import { observableConfigValue } from '../../../../../platform/observable/common/platformObservableUtils.js' ;
35
35
import { editorSelectionBackground } from '../../../../../platform/theme/common/colorRegistry.js' ;
36
- import { IUndoRedoService } from '../../../../../platform/undoRedo/common/undoRedo.js' ;
36
+ import { IUndoRedoElement , IUndoRedoService } from '../../../../../platform/undoRedo/common/undoRedo.js' ;
37
37
import { SaveReason , IEditorPane } from '../../../../common/editor.js' ;
38
38
import { IFilesConfigurationService } from '../../../../services/filesConfiguration/common/filesConfigurationService.js' ;
39
39
import { IResolvedTextFileEditorModel , stringToSnapshot } from '../../../../services/textfile/common/textfiles.js' ;
@@ -107,8 +107,8 @@ export class ChatEditingModifiedDocumentEntry extends AbstractChatEditingModifie
107
107
@IFilesConfigurationService fileConfigService : IFilesConfigurationService ,
108
108
@IChatService chatService : IChatService ,
109
109
@IEditorWorkerService private readonly _editorWorkerService : IEditorWorkerService ,
110
- @IUndoRedoService private readonly _undoRedoService : IUndoRedoService ,
111
110
@IFileService fileService : IFileService ,
111
+ @IUndoRedoService undoRedoService : IUndoRedoService ,
112
112
@IInstantiationService instantiationService : IInstantiationService
113
113
) {
114
114
super (
@@ -119,6 +119,7 @@ export class ChatEditingModifiedDocumentEntry extends AbstractChatEditingModifie
119
119
fileConfigService ,
120
120
chatService ,
121
121
fileService ,
122
+ undoRedoService ,
122
123
instantiationService
123
124
) ;
124
125
@@ -199,12 +200,9 @@ export class ChatEditingModifiedDocumentEntry extends AbstractChatEditingModifie
199
200
this . _setDocValue ( this . initialContent ) ;
200
201
}
201
202
202
- override async acceptStreamingEditsEnd ( tx : ITransaction ) {
203
+ protected override async _areOriginalAndModifiedIdentical ( ) : Promise < boolean > {
203
204
const diff = await this . _diffOperation ;
204
- super . acceptStreamingEditsEnd ( tx ) ;
205
- if ( diff ?. identical ) {
206
- this . accept ( tx ) ;
207
- }
205
+ return diff ? diff . identical : false ;
208
206
}
209
207
210
208
protected override _resetEditsState ( tx : ITransaction ) : void {
@@ -266,13 +264,10 @@ export class ChatEditingModifiedDocumentEntry extends AbstractChatEditingModifie
266
264
}
267
265
}
268
266
269
- override acceptStreamingEditsStart ( responseModel : IChatResponseModel , tx : ITransaction ) {
270
- super . acceptStreamingEditsStart ( responseModel , tx ) ;
271
-
272
- // push stack element whenever streaming starts
273
- const request = responseModel . session . getRequests ( ) . find ( req => req . id === responseModel . requestId ) ;
267
+ protected override _createUndoRedoElement ( response : IChatResponseModel ) : IUndoRedoElement {
268
+ const request = response . session . getRequests ( ) . find ( req => req . id === response . requestId ) ;
274
269
const label = request ?. message . text ? localize ( 'chatEditing1' , "Chat Edit: '{0}'" , request . message . text ) : localize ( 'chatEditing2' , "Chat Edit" ) ;
275
- this . _undoRedoService . pushElement ( new SingleModelEditStackElement ( label , 'chat.edit' , this . modifiedModel , null ) ) ;
270
+ return new SingleModelEditStackElement ( label , 'chat.edit' , this . modifiedModel , null ) ;
276
271
}
277
272
278
273
async acceptAgentEdits ( resource : URI , textEdits : ( TextEdit | ICellEditOperation ) [ ] , isLastEdits : boolean , responseModel : IChatResponseModel ) : Promise < void > {
0 commit comments