@@ -10,7 +10,6 @@ import { Emitter } from 'vs/base/common/event';
10
10
import { Selection } from 'vs/editor/common/core/selection' ;
11
11
import { Disposable } from 'vs/base/common/lifecycle' ;
12
12
import { CursorChangeReason } from 'vs/editor/common/cursorEvents' ;
13
- import { IModelContentChangedEvent , IModelDecorationsChangedEvent , IModelLanguageChangedEvent , IModelLanguageConfigurationChangedEvent , IModelOptionsChangedEvent , IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents' ;
14
13
15
14
export class ViewModelEventDispatcher extends Disposable {
16
15
@@ -41,9 +40,8 @@ export class ViewModelEventDispatcher extends Disposable {
41
40
42
41
private _addOutgoingEvent ( e : OutgoingViewModelEvent ) : void {
43
42
for ( let i = 0 , len = this . _outgoingEvents . length ; i < len ; i ++ ) {
44
- const mergeResult = ( this . _outgoingEvents [ i ] . kind === e . kind ? this . _outgoingEvents [ i ] . attemptToMerge ( e ) : null ) ;
45
- if ( mergeResult ) {
46
- this . _outgoingEvents [ i ] = mergeResult ;
43
+ if ( this . _outgoingEvents [ i ] . kind === e . kind ) {
44
+ this . _outgoingEvents [ i ] = this . _outgoingEvents [ i ] . merge ( e ) ;
47
45
return ;
48
46
}
49
47
}
@@ -181,12 +179,6 @@ export type OutgoingViewModelEvent = (
181
179
| HiddenAreasChangedEvent
182
180
| ReadOnlyEditAttemptEvent
183
181
| CursorStateChangedEvent
184
- | ModelDecorationsChangedEvent
185
- | ModelLanguageChangedEvent
186
- | ModelLanguageConfigurationChangedEvent
187
- | ModelContentChangedEvent
188
- | ModelOptionsChangedEvent
189
- | ModelTokensChangedEvent
190
182
) ;
191
183
192
184
export const enum OutgoingViewModelEventKind {
@@ -197,12 +189,6 @@ export const enum OutgoingViewModelEventKind {
197
189
HiddenAreasChanged ,
198
190
ReadOnlyEditAttempt ,
199
191
CursorStateChanged ,
200
- ModelDecorationsChanged ,
201
- ModelLanguageChanged ,
202
- ModelLanguageConfigurationChanged ,
203
- ModelContentChanged ,
204
- ModelOptionsChanged ,
205
- ModelTokensChanged ,
206
192
}
207
193
208
194
export class ContentSizeChangedEvent implements IContentSizeChangedEvent {
@@ -230,9 +216,10 @@ export class ContentSizeChangedEvent implements IContentSizeChangedEvent {
230
216
return ( ! this . contentWidthChanged && ! this . contentHeightChanged ) ;
231
217
}
232
218
233
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
234
- if ( other . kind !== this . kind ) {
235
- return null ;
219
+
220
+ public merge ( other : OutgoingViewModelEvent ) : ContentSizeChangedEvent {
221
+ if ( other . kind !== OutgoingViewModelEventKind . ContentSizeChanged ) {
222
+ return this ;
236
223
}
237
224
return new ContentSizeChangedEvent ( this . _oldContentWidth , this . _oldContentHeight , other . contentWidth , other . contentHeight ) ;
238
225
}
@@ -254,9 +241,9 @@ export class FocusChangedEvent {
254
241
return ( this . oldHasFocus === this . hasFocus ) ;
255
242
}
256
243
257
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
258
- if ( other . kind !== this . kind ) {
259
- return null ;
244
+ public merge ( other : OutgoingViewModelEvent ) : FocusChangedEvent {
245
+ if ( other . kind !== OutgoingViewModelEventKind . FocusChanged ) {
246
+ return this ;
260
247
}
261
248
return new FocusChangedEvent ( this . oldHasFocus , other . hasFocus ) ;
262
249
}
@@ -305,9 +292,9 @@ export class ScrollChangedEvent {
305
292
return ( ! this . scrollWidthChanged && ! this . scrollLeftChanged && ! this . scrollHeightChanged && ! this . scrollTopChanged ) ;
306
293
}
307
294
308
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
309
- if ( other . kind !== this . kind ) {
310
- return null ;
295
+ public merge ( other : OutgoingViewModelEvent ) : ScrollChangedEvent {
296
+ if ( other . kind !== OutgoingViewModelEventKind . ScrollChanged ) {
297
+ return this ;
311
298
}
312
299
return new ScrollChangedEvent (
313
300
this . _oldScrollWidth , this . _oldScrollLeft , this . _oldScrollHeight , this . _oldScrollTop ,
@@ -327,10 +314,7 @@ export class ViewZonesChangedEvent {
327
314
return false ;
328
315
}
329
316
330
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
331
- if ( other . kind !== this . kind ) {
332
- return null ;
333
- }
317
+ public merge ( other : OutgoingViewModelEvent ) : ViewZonesChangedEvent {
334
318
return this ;
335
319
}
336
320
}
@@ -346,10 +330,7 @@ export class HiddenAreasChangedEvent {
346
330
return false ;
347
331
}
348
332
349
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
350
- if ( other . kind !== this . kind ) {
351
- return null ;
352
- }
333
+ public merge ( other : OutgoingViewModelEvent ) : HiddenAreasChangedEvent {
353
334
return this ;
354
335
}
355
336
}
@@ -403,9 +384,9 @@ export class CursorStateChangedEvent {
403
384
) ;
404
385
}
405
386
406
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
407
- if ( other . kind !== this . kind ) {
408
- return null ;
387
+ public merge ( other : OutgoingViewModelEvent ) : CursorStateChangedEvent {
388
+ if ( other . kind !== OutgoingViewModelEventKind . CursorStateChanged ) {
389
+ return this ;
409
390
}
410
391
return new CursorStateChangedEvent (
411
392
this . oldSelections , other . selections , this . oldModelVersionId , other . modelVersionId , other . source , other . reason , this . reachedMaxCursorCount || other . reachedMaxCursorCount
@@ -424,106 +405,7 @@ export class ReadOnlyEditAttemptEvent {
424
405
return false ;
425
406
}
426
407
427
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
428
- if ( other . kind !== this . kind ) {
429
- return null ;
430
- }
408
+ public merge ( other : OutgoingViewModelEvent ) : ReadOnlyEditAttemptEvent {
431
409
return this ;
432
410
}
433
411
}
434
-
435
- export class ModelDecorationsChangedEvent {
436
- public readonly kind = OutgoingViewModelEventKind . ModelDecorationsChanged ;
437
-
438
- constructor (
439
- public readonly event : IModelDecorationsChangedEvent
440
- ) { }
441
-
442
- public isNoOp ( ) : boolean {
443
- return false ;
444
- }
445
-
446
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
447
- return null ;
448
- }
449
- }
450
-
451
- export class ModelLanguageChangedEvent {
452
- public readonly kind = OutgoingViewModelEventKind . ModelLanguageChanged ;
453
-
454
- constructor (
455
- public readonly event : IModelLanguageChangedEvent
456
- ) { }
457
-
458
- public isNoOp ( ) : boolean {
459
- return false ;
460
- }
461
-
462
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
463
- return null ;
464
- }
465
- }
466
-
467
- export class ModelLanguageConfigurationChangedEvent {
468
- public readonly kind = OutgoingViewModelEventKind . ModelLanguageConfigurationChanged ;
469
-
470
- constructor (
471
- public readonly event : IModelLanguageConfigurationChangedEvent
472
- ) { }
473
-
474
- public isNoOp ( ) : boolean {
475
- return false ;
476
- }
477
-
478
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
479
- return null ;
480
- }
481
- }
482
-
483
- export class ModelContentChangedEvent {
484
- public readonly kind = OutgoingViewModelEventKind . ModelContentChanged ;
485
-
486
- constructor (
487
- public readonly event : IModelContentChangedEvent
488
- ) { }
489
-
490
- public isNoOp ( ) : boolean {
491
- return false ;
492
- }
493
-
494
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
495
- return null ;
496
- }
497
- }
498
-
499
- export class ModelOptionsChangedEvent {
500
- public readonly kind = OutgoingViewModelEventKind . ModelOptionsChanged ;
501
-
502
- constructor (
503
- public readonly event : IModelOptionsChangedEvent
504
- ) { }
505
-
506
- public isNoOp ( ) : boolean {
507
- return false ;
508
- }
509
-
510
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
511
- return null ;
512
- }
513
- }
514
-
515
- export class ModelTokensChangedEvent {
516
- public readonly kind = OutgoingViewModelEventKind . ModelTokensChanged ;
517
-
518
- constructor (
519
- public readonly event : IModelTokensChangedEvent
520
- ) { }
521
-
522
- public isNoOp ( ) : boolean {
523
- return false ;
524
- }
525
-
526
- public attemptToMerge ( other : OutgoingViewModelEvent ) : OutgoingViewModelEvent | null {
527
- return null ;
528
- }
529
- }
0 commit comments