@@ -15,16 +15,15 @@ import { Selection } from 'vs/editor/common/core/selection';
15
15
import { LineRangeMapping } from 'vs/editor/common/diff/linesDiffComputer' ;
16
16
import { IEditorDecorationsCollection } from 'vs/editor/common/editorCommon' ;
17
17
import { ICursorStateComputer , IModelDecorationOptions , IModelDeltaDecoration , IValidEditOperation } from 'vs/editor/common/model' ;
18
- import { createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel' ;
19
18
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker' ;
20
- import { IModelService } from 'vs/editor/common/services/model' ;
21
19
import { localize } from 'vs/nls' ;
22
20
import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
23
21
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
24
22
import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
25
23
import { InteractiveEditorFileCreatePreviewWidget , InteractiveEditorLivePreviewWidget } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorLivePreviewWidget' ;
26
24
import { EditResponse , Session } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession' ;
27
25
import { InteractiveEditorWidget } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget' ;
26
+ import { getValueFromSnapshot } from 'vs/workbench/contrib/interactiveEditor/browser/utils' ;
28
27
import { CTX_INTERACTIVE_EDITOR_INLNE_DIFF , CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
29
28
30
29
export abstract class EditModeStrategy {
@@ -209,7 +208,6 @@ export class LiveStrategy extends EditModeStrategy {
209
208
@IStorageService protected _storageService : IStorageService ,
210
209
@IBulkEditService protected readonly _bulkEditService : IBulkEditService ,
211
210
@IEditorWorkerService protected readonly _editorWorkerService : IEditorWorkerService ,
212
- @IModelService private readonly _modelService : IModelService
213
211
) {
214
212
super ( ) ;
215
213
this . _inlineDiffDecorations = new InlineDiffDecorations ( this . _editor , this . _inlineDiffEnabled ) ;
@@ -265,8 +263,11 @@ export class LiveStrategy extends EditModeStrategy {
265
263
return ;
266
264
}
267
265
268
- const initialTextModel = lastSnapshot ? this . _modelService . createModel ( createTextBufferFactoryFromSnapshot ( lastSnapshot ) , null ) : model0 ;
269
- const edits = await this . _editorWorkerService . computeMoreMinimalEdits ( modelN . uri , [ { range : modelN . getFullModelRange ( ) , text : initialTextModel . getValue ( ) } ] ) ;
266
+ const newText = lastSnapshot
267
+ ? getValueFromSnapshot ( lastSnapshot )
268
+ : model0 . getValue ( ) ;
269
+
270
+ const edits = await this . _editorWorkerService . computeMoreMinimalEdits ( modelN . uri , [ { range : modelN . getFullModelRange ( ) , text : newText } ] ) ;
270
271
if ( edits ) {
271
272
const operations = edits . map ( e => EditOperation . replace ( Range . lift ( e . range ) , e . text ) ) ;
272
273
modelN . pushEditOperations ( null , operations , ( ) => null ) ;
@@ -331,9 +332,8 @@ export class LivePreviewStrategy extends LiveStrategy {
331
332
@IBulkEditService bulkEditService : IBulkEditService ,
332
333
@IEditorWorkerService editorWorkerService : IEditorWorkerService ,
333
334
@IInstantiationService instaService : IInstantiationService ,
334
- @IModelService modelService : IModelService
335
335
) {
336
- super ( session , editor , widget , contextKeyService , storageService , bulkEditService , editorWorkerService , modelService ) ;
336
+ super ( session , editor , widget , contextKeyService , storageService , bulkEditService , editorWorkerService ) ;
337
337
338
338
this . _diffZone = instaService . createInstance ( InteractiveEditorLivePreviewWidget , editor , session . textModel0 ) ;
339
339
this . _previewZone = instaService . createInstance ( InteractiveEditorFileCreatePreviewWidget , editor ) ;
0 commit comments