@@ -27,12 +27,6 @@ import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/
27
27
28
28
export abstract class EditModeStrategy {
29
29
30
- constructor ( protected readonly _editor : ICodeEditor ) {
31
- this . _initialPosition = this . _editor . getPosition ( ) ;
32
- }
33
-
34
- protected _initialPosition : Position | null ;
35
-
36
30
abstract dispose ( ) : void ;
37
31
38
32
abstract checkChanges ( response : EditResponse ) : boolean ;
@@ -49,7 +43,7 @@ export abstract class EditModeStrategy {
49
43
50
44
abstract hasFocus ( ) : boolean ;
51
45
52
- abstract getWidgetPosition ( initialRender : boolean , range : Range ) : Position | null ;
46
+ abstract getWidgetPosition ( ) : Position | null ;
53
47
}
54
48
55
49
export class PreviewStrategy extends EditModeStrategy {
@@ -58,14 +52,13 @@ export class PreviewStrategy extends EditModeStrategy {
58
52
private readonly _listener : IDisposable ;
59
53
60
54
constructor (
61
- _editor : ICodeEditor ,
62
55
private readonly _session : Session ,
63
56
private readonly _widget : InlineChatWidget ,
64
57
@IContextKeyService contextKeyService : IContextKeyService ,
65
58
@IBulkEditService private readonly _bulkEditService : IBulkEditService ,
66
59
@IInstantiationService private readonly _instaService : IInstantiationService ,
67
60
) {
68
- super ( _editor ) ;
61
+ super ( ) ;
69
62
70
63
this . _ctxDocumentChanged = CTX_INLINE_CHAT_DOCUMENT_CHANGED . bindTo ( contextKeyService ) ;
71
64
this . _listener = Event . debounce ( _session . textModelN . onDidChangeContent . bind ( _session . textModelN ) , ( ) => { } , 350 ) ( _ => {
@@ -138,8 +131,8 @@ export class PreviewStrategy extends EditModeStrategy {
138
131
// nothing to do
139
132
}
140
133
141
- getWidgetPosition ( _initialRender : boolean , _range : Range ) : Position | null {
142
- return this . _initialPosition ;
134
+ getWidgetPosition ( ) : Position | null {
135
+ return null ;
143
136
}
144
137
145
138
hasFocus ( ) : boolean {
@@ -225,16 +218,16 @@ export class LiveStrategy extends EditModeStrategy {
225
218
private _editCount : number = 0 ;
226
219
227
220
constructor (
228
- _editor : ICodeEditor ,
229
221
protected readonly _session : Session ,
222
+ protected readonly _editor : ICodeEditor ,
230
223
protected readonly _widget : InlineChatWidget ,
231
224
@IContextKeyService contextKeyService : IContextKeyService ,
232
225
@IStorageService protected _storageService : IStorageService ,
233
226
@IBulkEditService protected readonly _bulkEditService : IBulkEditService ,
234
227
@IEditorWorkerService protected readonly _editorWorkerService : IEditorWorkerService ,
235
228
@IInstantiationService private readonly _instaService : IInstantiationService ,
236
229
) {
237
- super ( _editor ) ;
230
+ super ( ) ;
238
231
this . _diffEnabled = _storageService . getBoolean ( LiveStrategy . _inlineDiffStorageKey , StorageScope . PROFILE , true ) ;
239
232
240
233
this . _inlineDiffDecorations = new InlineDiffDecorations ( this . _editor , this . _diffEnabled ) ;
@@ -350,18 +343,13 @@ export class LiveStrategy extends EditModeStrategy {
350
343
return lastLineOfLocalEdits ;
351
344
}
352
345
353
- override getWidgetPosition ( initialRender : boolean , _range : Range ) : Position | null {
354
- if ( initialRender ) {
355
- return this . _initialPosition ;
356
- } else {
357
- const isEditResponse = this . _session . lastExchange ?. response instanceof EditResponse ;
358
- if ( isEditResponse ) {
359
- const lastLineOfLocalEdits = this . _lastLineOfLocalEdits ( ) ;
360
- return lastLineOfLocalEdits ? new Position ( lastLineOfLocalEdits , 1 ) : this . _initialPosition ;
361
- } else {
362
- return this . _initialPosition ;
363
- }
346
+ override getWidgetPosition ( ) : Position | null {
347
+ const isEditResponse = this . _session . lastExchange ?. response instanceof EditResponse ;
348
+ if ( isEditResponse ) {
349
+ const lastLineOfLocalEdits = this . _lastLineOfLocalEdits ( ) ;
350
+ return lastLineOfLocalEdits ? new Position ( lastLineOfLocalEdits , 1 ) : null ;
364
351
}
352
+ return null ;
365
353
}
366
354
367
355
hasFocus ( ) : boolean {
@@ -375,16 +363,16 @@ export class LivePreviewStrategy extends LiveStrategy {
375
363
private readonly _previewZone : InlineChatFileCreatePreviewWidget ;
376
364
377
365
constructor (
378
- editor : ICodeEditor ,
379
366
session : Session ,
367
+ editor : ICodeEditor ,
380
368
widget : InlineChatWidget ,
381
369
@IContextKeyService contextKeyService : IContextKeyService ,
382
370
@IStorageService storageService : IStorageService ,
383
371
@IBulkEditService bulkEditService : IBulkEditService ,
384
372
@IEditorWorkerService editorWorkerService : IEditorWorkerService ,
385
373
@IInstantiationService instaService : IInstantiationService ,
386
374
) {
387
- super ( editor , session , widget , contextKeyService , storageService , bulkEditService , editorWorkerService , instaService ) ;
375
+ super ( session , editor , widget , contextKeyService , storageService , bulkEditService , editorWorkerService , instaService ) ;
388
376
389
377
this . _diffZone = instaService . createInstance ( InlineChatLivePreviewWidget , editor , session ) ;
390
378
this . _previewZone = instaService . createInstance ( InlineChatFileCreatePreviewWidget , editor ) ;
@@ -422,17 +410,12 @@ export class LivePreviewStrategy extends LiveStrategy {
422
410
scrollState . restore ( this . _editor ) ;
423
411
}
424
412
425
- override getWidgetPosition ( initialRender : boolean , range : Range ) : Position | null {
426
- if ( initialRender ) {
427
- return this . _initialPosition ;
428
- } else {
429
- const isEditResponse = this . _session . lastExchange ?. response instanceof EditResponse ;
430
- if ( range && isEditResponse ) {
431
- return range . getEndPosition ( ) ;
432
- } else {
433
- return this . _initialPosition ;
434
- }
413
+ override getWidgetPosition ( ) : Position | null {
414
+ const isEditResponse = this . _session . lastExchange ?. response instanceof EditResponse ;
415
+ if ( isEditResponse ) {
416
+ return this . _session . wholeRange . value . getEndPosition ( ) ;
435
417
}
418
+ return null ;
436
419
}
437
420
438
421
override hasFocus ( ) : boolean {
0 commit comments