@@ -10,7 +10,7 @@ import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
10
10
import { EmbeddedCodeEditorWidget , EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget' ;
11
11
import { EditorOption } from 'vs/editor/common/config/editorOptions' ;
12
12
import { Range } from 'vs/editor/common/core/range' ;
13
- import { IModelDecorationOptions , IModelDeltaDecoration , ITextModel } from 'vs/editor/common/model' ;
13
+ import { ITextModel } from 'vs/editor/common/model' ;
14
14
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget' ;
15
15
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
16
16
import * as colorRegistry from 'vs/platform/theme/common/colorRegistry' ;
@@ -21,7 +21,7 @@ import { LineRange } from 'vs/editor/common/core/lineRange';
21
21
import { LineRangeMapping } from 'vs/editor/common/diff/linesDiffComputer' ;
22
22
import { Position } from 'vs/editor/common/core/position' ;
23
23
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions' ;
24
- import { IEditorDecorationsCollection , ScrollType } from 'vs/editor/common/editorCommon' ;
24
+ import { ScrollType } from 'vs/editor/common/editorCommon' ;
25
25
import { ILogService } from 'vs/platform/log/common/log' ;
26
26
import { lineRangeAsRange , invertLineRange } from 'vs/workbench/contrib/inlineChat/browser/utils' ;
27
27
import { ResourceLabel } from 'vs/workbench/browser/labels' ;
@@ -43,7 +43,6 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
43
43
44
44
private readonly _sessionStore = this . _disposables . add ( new DisposableStore ( ) ) ;
45
45
private readonly _diffEditor : IDiffEditor ;
46
- private readonly _inlineDiffDecorations : IEditorDecorationsCollection ;
47
46
private _dim : Dimension | undefined ;
48
47
private _isVisible : boolean = false ;
49
48
private _isDiffLocked : boolean = false ;
@@ -59,8 +58,6 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
59
58
super . create ( ) ;
60
59
assertType ( editor . hasModel ( ) ) ;
61
60
62
- this . _inlineDiffDecorations = editor . createDecorationsCollection ( ) ;
63
-
64
61
const diffContributions = EditorExtensionsRegistry
65
62
. getEditorContributions ( )
66
63
. filter ( c => c . id !== INLINE_CHAT_ID && c . id !== FoldingController . ID ) ;
@@ -120,10 +117,6 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
120
117
this . _disposables . add ( themeService . onDidColorThemeChange ( doStyle ) ) ;
121
118
}
122
119
123
- override dispose ( ) : void {
124
- this . _inlineDiffDecorations . clear ( ) ;
125
- super . dispose ( ) ;
126
- }
127
120
128
121
protected override _fillContainer ( container : HTMLElement ) : void {
129
122
container . appendChild ( this . _elements . domNode ) ;
@@ -137,7 +130,6 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
137
130
138
131
override hide ( ) : void {
139
132
this . _cleanupFullDiff ( ) ;
140
- this . _cleanupInlineDiff ( ) ;
141
133
this . _sessionStore . clear ( ) ;
142
134
super . hide ( ) ;
143
135
this . _isVisible = false ;
@@ -175,70 +167,9 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
175
167
return ;
176
168
}
177
169
178
- if ( changes . length === 0 || this . _session . textModel0 . getValueLength ( ) === 0 ) {
179
- // no change or changes to an empty file
180
- this . _logService . debug ( '[IE] livePreview-mode: no diff' ) ;
181
- this . hide ( ) ;
182
-
183
- } else if ( changes . every ( isInlineDiffFriendly ) ) {
184
- // simple changes
185
- this . _logService . debug ( '[IE] livePreview-mode: inline diff' ) ;
186
- this . _cleanupFullDiff ( ) ;
187
- this . _renderChangesWithInlineDiff ( changes ) ;
188
-
189
- } else {
190
- // complex changes
191
- this . _logService . debug ( '[IE] livePreview-mode: full diff' ) ;
192
- this . _cleanupInlineDiff ( ) ;
193
- this . _renderChangesWithFullDiff ( changes , range ) ;
194
- }
195
- }
196
-
197
- // --- inline diff
198
-
199
- private _renderChangesWithInlineDiff ( changes : readonly LineRangeMapping [ ] ) {
200
- const original = this . _session . textModel0 ;
201
-
202
- const decorations : IModelDeltaDecoration [ ] = [ ] ;
203
-
204
- for ( const { innerChanges } of changes ) {
205
- if ( ! innerChanges ) {
206
- continue ;
207
- }
208
- for ( const { modifiedRange, originalRange } of innerChanges ) {
209
-
210
- const options : IModelDecorationOptions = {
211
- description : 'interactive-diff-inline' ,
212
- showIfCollapsed : true ,
213
- } ;
214
-
215
- if ( ! modifiedRange . isEmpty ( ) ) {
216
- options . className = 'inline-chat-lines-inserted-range' ;
217
- }
218
-
219
- if ( ! originalRange . isEmpty ( ) ) {
220
- let content = original . getValueInRange ( originalRange ) ;
221
- if ( content . length > 7 ) {
222
- content = content . substring ( 0 , 7 ) + '…' ;
223
- }
224
- options . before = {
225
- content,
226
- inlineClassName : 'inline-chat-lines-deleted-range-inline'
227
- } ;
228
- }
229
-
230
- decorations . push ( {
231
- range : modifiedRange ,
232
- options
233
- } ) ;
234
- }
235
- }
236
-
237
- this . _inlineDiffDecorations . set ( decorations ) ;
238
- }
239
-
240
- private _cleanupInlineDiff ( ) {
241
- this . _inlineDiffDecorations . clear ( ) ;
170
+ // complex changes
171
+ this . _logService . debug ( '[IE] livePreview-mode: full diff' ) ;
172
+ this . _renderChangesWithFullDiff ( changes , range ) ;
242
173
}
243
174
244
175
// --- full diff
@@ -273,7 +204,9 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
273
204
}
274
205
275
206
private _computeHiddenRanges ( model : ITextModel , range : Range , changes : readonly LineRangeMapping [ ] ) {
276
- assertType ( changes . length > 0 ) ;
207
+ if ( changes . length === 0 ) {
208
+ changes = [ new LineRangeMapping ( LineRange . fromRange ( range ) , LineRange . fromRange ( range ) , undefined ) ] ;
209
+ }
277
210
278
211
let originalLineRange = changes [ 0 ] . originalRange ;
279
212
let modifiedLineRange = changes [ 0 ] . modifiedRange ;
@@ -347,21 +280,6 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
347
280
}
348
281
}
349
282
350
- function isInlineDiffFriendly ( mapping : LineRangeMapping ) : boolean {
351
- if ( ! mapping . modifiedRange . equals ( mapping . originalRange ) ) {
352
- return false ;
353
- }
354
- if ( ! mapping . innerChanges ) {
355
- return false ;
356
- }
357
- for ( const { modifiedRange, originalRange } of mapping . innerChanges ) {
358
- if ( Range . spansMultipleLines ( modifiedRange ) || Range . spansMultipleLines ( originalRange ) ) {
359
- return false ;
360
- }
361
- }
362
- return true ;
363
- }
364
-
365
283
366
284
export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
367
285
0 commit comments