@@ -47,6 +47,8 @@ export class DomRenderer extends Disposable implements IRenderer {
4747 private _selectionRenderModel : ISelectionRenderModel = createSelectionRenderModel ( ) ;
4848 private _cursorBlinkStateManager : CursorBlinkStateManager ;
4949 private _textBlinkStateManager : TextBlinkStateManager ;
50+ private _rowHasBlinkingCells : boolean [ ] = [ ] ;
51+ private _rowHasBlinkingCellsCount : number = 0 ;
5052
5153 public dimensions : IRenderDimensions ;
5254
@@ -329,10 +331,14 @@ export class DomRenderer extends Disposable implements IRenderer {
329331 const row = this . _document . createElement ( 'div' ) ;
330332 this . _rowContainer . appendChild ( row ) ;
331333 this . _rowElements . push ( row ) ;
334+ this . _rowHasBlinkingCells . push ( false ) ;
332335 }
333336 // Remove excess elements
334337 while ( this . _rowElements . length > rows ) {
335338 this . _rowContainer . removeChild ( this . _rowElements . pop ( ) ! ) ;
339+ if ( this . _rowHasBlinkingCells . pop ( ) ) {
340+ this . _rowHasBlinkingCellsCount -- ;
341+ }
336342 }
337343 }
338344
@@ -360,6 +366,10 @@ export class DomRenderer extends Disposable implements IRenderer {
360366 this . renderRows ( this . _bufferService . buffer . y , this . _bufferService . buffer . y ) ;
361367 }
362368
369+ public handleViewportVisibilityChange ( isVisible : boolean ) : void {
370+ this . _textBlinkStateManager . setViewportVisible ( isVisible ) ;
371+ }
372+
363373 public handleSelectionChanged ( start : [ number , number ] | undefined , end : [ number , number ] | undefined , columnSelectMode : boolean ) : void {
364374 // Remove all selections
365375 this . _selectionContainer . replaceChildren ( ) ;
@@ -461,6 +471,11 @@ export class DomRenderer extends Disposable implements IRenderer {
461471 */
462472 e . replaceChildren ( ) ;
463473 }
474+ if ( this . _rowHasBlinkingCellsCount > 0 ) {
475+ this . _rowHasBlinkingCells . fill ( false ) ;
476+ this . _rowHasBlinkingCellsCount = 0 ;
477+ this . _textBlinkStateManager . setNeedsBlinkInViewport ( false ) ;
478+ }
464479 }
465480
466481 public renderRows ( start : number , end : number ) : void {
@@ -470,6 +485,7 @@ export class DomRenderer extends Disposable implements IRenderer {
470485 const cursorBlink = this . _coreService . decPrivateModes . cursorBlink ?? this . _optionsService . rawOptions . cursorBlink ;
471486 const cursorStyle = this . _coreService . decPrivateModes . cursorStyle ?? this . _optionsService . rawOptions . cursorStyle ;
472487 const cursorInactiveStyle = this . _optionsService . rawOptions . cursorInactiveStyle ;
488+ const rowInfo = { hasBlinkingCells : false } ;
473489
474490 for ( let y = start ; y <= end ; y ++ ) {
475491 const row = y + buffer . ydisp ;
@@ -491,10 +507,13 @@ export class DomRenderer extends Disposable implements IRenderer {
491507 this . dimensions . css . cell . width ,
492508 this . _widthCache ,
493509 - 1 ,
494- - 1
510+ - 1 ,
511+ rowInfo
495512 )
496513 ) ;
514+ this . _setRowBlinkState ( y , rowInfo . hasBlinkingCells ) ;
497515 }
516+ this . _updateTextBlinkState ( ) ;
498517 }
499518
500519 private get _terminalSelector ( ) : string {
@@ -539,6 +558,7 @@ export class DomRenderer extends Disposable implements IRenderer {
539558 const cursorBlink = this . _optionsService . rawOptions . cursorBlink ;
540559 const cursorStyle = this . _optionsService . rawOptions . cursorStyle ;
541560 const cursorInactiveStyle = this . _optionsService . rawOptions . cursorInactiveStyle ;
561+ const rowInfo = { hasBlinkingCells : false } ;
542562
543563 // refresh rows within link range
544564 for ( let i = y ; i <= y2 ; ++ i ) {
@@ -561,10 +581,26 @@ export class DomRenderer extends Disposable implements IRenderer {
561581 this . dimensions . css . cell . width ,
562582 this . _widthCache ,
563583 enabled ? ( i === y ? x : 0 ) : - 1 ,
564- enabled ? ( ( i === y2 ? x2 : cols ) - 1 ) : - 1
584+ enabled ? ( ( i === y2 ? x2 : cols ) - 1 ) : - 1 ,
585+ rowInfo
565586 )
566587 ) ;
588+ this . _setRowBlinkState ( i , rowInfo . hasBlinkingCells ) ;
567589 }
590+ this . _updateTextBlinkState ( ) ;
591+ }
592+
593+ private _setRowBlinkState ( row : number , hasBlinkingCells : boolean ) : void {
594+ const previous = this . _rowHasBlinkingCells [ row ] ;
595+ if ( previous === hasBlinkingCells ) {
596+ return ;
597+ }
598+ this . _rowHasBlinkingCells [ row ] = hasBlinkingCells ;
599+ this . _rowHasBlinkingCellsCount += hasBlinkingCells ? 1 : - 1 ;
600+ }
601+
602+ private _updateTextBlinkState ( ) : void {
603+ this . _textBlinkStateManager . setNeedsBlinkInViewport ( this . _rowHasBlinkingCellsCount > 0 ) ;
568604 }
569605}
570606
0 commit comments