6
6
import { disposableWindowInterval } from 'vs/base/browser/dom' ;
7
7
import { $window } from 'vs/base/browser/window' ;
8
8
import { IAction , toAction } from 'vs/base/common/actions' ;
9
- import { equals , tail } from 'vs/base/common/arrays' ;
9
+ import { coalesceInPlace , equals , tail } from 'vs/base/common/arrays' ;
10
10
import { AsyncIterableObject , AsyncIterableSource } from 'vs/base/common/async' ;
11
11
import { CancellationToken } from 'vs/base/common/cancellation' ;
12
12
import { Codicon } from 'vs/base/common/codicons' ;
@@ -45,6 +45,14 @@ import { CTX_INLINE_CHAT_CHANGE_HAS_DIFF, CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF, CTX
45
45
46
46
export abstract class EditModeStrategy {
47
47
48
+ protected static _decoBlock = ModelDecorationOptions . register ( {
49
+ description : 'inline-chat' ,
50
+ showIfCollapsed : false ,
51
+ isWholeLine : true ,
52
+ className : 'inline-chat-block-selection' ,
53
+ } ) ;
54
+
55
+
48
56
protected readonly _onDidAccept = new Emitter < void > ( ) ;
49
57
protected readonly _onDidDiscard = new Emitter < void > ( ) ;
50
58
@@ -53,7 +61,10 @@ export abstract class EditModeStrategy {
53
61
54
62
toggleDiff ?: ( ) => any ;
55
63
56
- constructor ( protected readonly _zone : InlineChatZoneWidget ) { }
64
+ constructor (
65
+ protected readonly _session : Session ,
66
+ protected readonly _zone : InlineChatZoneWidget ,
67
+ ) { }
57
68
58
69
dispose ( ) : void {
59
70
this . _onDidAccept . dispose ( ) ;
@@ -75,6 +86,13 @@ export abstract class EditModeStrategy {
75
86
abstract renderChanges ( response : ReplyResponse ) : Promise < Position | undefined > ;
76
87
77
88
abstract hasFocus ( ) : boolean ;
89
+
90
+ getWholeRangeDecoration ( ) : IModelDeltaDecoration [ ] {
91
+ const ranges = [ this . _session . wholeRange . value ] ;
92
+ const newDecorations = ranges . map ( range => range . isEmpty ( ) ? undefined : ( { range, options : EditModeStrategy . _decoBlock } ) ) ;
93
+ coalesceInPlace ( newDecorations ) ;
94
+ return newDecorations ;
95
+ }
78
96
}
79
97
80
98
export class PreviewStrategy extends EditModeStrategy {
@@ -83,16 +101,16 @@ export class PreviewStrategy extends EditModeStrategy {
83
101
private readonly _listener : IDisposable ;
84
102
85
103
constructor (
86
- private readonly _session : Session ,
104
+ session : Session ,
87
105
zone : InlineChatZoneWidget ,
88
106
@IContextKeyService contextKeyService : IContextKeyService ,
89
107
) {
90
- super ( zone ) ;
108
+ super ( session , zone ) ;
91
109
92
110
this . _ctxDocumentChanged = CTX_INLINE_CHAT_DOCUMENT_CHANGED . bindTo ( contextKeyService ) ;
93
- this . _listener = Event . debounce ( _session . textModelN . onDidChangeContent . bind ( _session . textModelN ) , ( ) => { } , 350 ) ( _ => {
94
- if ( ! _session . textModelN . isDisposed ( ) && ! _session . textModel0 . isDisposed ( ) ) {
95
- this . _ctxDocumentChanged . set ( _session . hasChangedText ) ;
111
+ this . _listener = Event . debounce ( session . textModelN . onDidChangeContent . bind ( session . textModelN ) , ( ) => { } , 350 ) ( _ => {
112
+ if ( ! session . textModelN . isDisposed ( ) && ! session . textModel0 . isDisposed ( ) ) {
113
+ this . _ctxDocumentChanged . set ( session . hasChangedText ) ;
96
114
}
97
115
} ) ;
98
116
}
@@ -179,15 +197,15 @@ export class LivePreviewStrategy extends EditModeStrategy {
179
197
private _editCount : number = 0 ;
180
198
181
199
constructor (
182
- private readonly _session : Session ,
200
+ session : Session ,
183
201
private readonly _editor : ICodeEditor ,
184
202
zone : InlineChatZoneWidget ,
185
203
@IStorageService storageService : IStorageService ,
186
204
@IBulkEditService bulkEditService : IBulkEditService ,
187
205
@IEditorWorkerService private readonly _editorWorkerService : IEditorWorkerService ,
188
206
@IInstantiationService private readonly _instaService : IInstantiationService ,
189
207
) {
190
- super ( zone ) ;
208
+ super ( session , zone ) ;
191
209
192
210
this . _previewZone = new Lazy ( ( ) => _instaService . createInstance ( InlineChatFileCreatePreviewWidget , _editor ) ) ;
193
211
}
@@ -500,16 +518,14 @@ export class LiveStrategy extends EditModeStrategy {
500
518
private _editCount : number = 0 ;
501
519
502
520
constructor (
503
- protected readonly _session : Session ,
521
+ session : Session ,
504
522
protected readonly _editor : ICodeEditor ,
505
523
zone : InlineChatZoneWidget ,
506
524
@IContextKeyService contextKeyService : IContextKeyService ,
507
- @IStorageService protected _storageService : IStorageService ,
508
- @IBulkEditService protected readonly _bulkEditService : IBulkEditService ,
509
525
@IEditorWorkerService protected readonly _editorWorkerService : IEditorWorkerService ,
510
526
@IInstantiationService protected readonly _instaService : IInstantiationService ,
511
527
) {
512
- super ( zone ) ;
528
+ super ( session , zone ) ;
513
529
this . _ctxCurrentChangeHasDiff = CTX_INLINE_CHAT_CHANGE_HAS_DIFF . bindTo ( contextKeyService ) ;
514
530
this . _ctxCurrentChangeShowsDiff = CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF . bindTo ( contextKeyService ) ;
515
531
@@ -893,6 +909,11 @@ export class LiveStrategy extends EditModeStrategy {
893
909
hasFocus ( ) : boolean {
894
910
return this . _zone . widget . hasFocus ( ) ;
895
911
}
912
+
913
+ override getWholeRangeDecoration ( ) : IModelDeltaDecoration [ ] {
914
+ // don't render the blue in live mode
915
+ return [ ] ;
916
+ }
896
917
}
897
918
898
919
0 commit comments