@@ -14,6 +14,7 @@ export class BufferDecorationRenderer extends Disposable {
1414
1515 private _animationFrame : number | undefined ;
1616 private _altBufferIsActive : boolean = false ;
17+ private _dimensionsChanged : boolean = false ;
1718
1819 constructor (
1920 private readonly _screenElement : HTMLElement ,
@@ -28,7 +29,10 @@ export class BufferDecorationRenderer extends Disposable {
2829 this . _screenElement . appendChild ( this . _container ) ;
2930
3031 this . register ( this . _renderService . onRenderedBufferChange ( ( ) => this . _queueRefresh ( ) ) ) ;
31- this . register ( this . _renderService . onDimensionsChange ( ( ) => this . _queueRefresh ( ) ) ) ;
32+ this . register ( this . _renderService . onDimensionsChange ( ( ) => {
33+ this . _dimensionsChanged = true ;
34+ this . _queueRefresh ( ) ;
35+ } ) ) ;
3236 this . register ( addDisposableDomListener ( window , 'resize' , ( ) => this . _queueRefresh ( ) ) ) ;
3337 this . register ( this . _bufferService . buffers . onBufferActivate ( ( ) => {
3438 this . _altBufferIsActive = this . _bufferService . buffer === this . _bufferService . buffers . alt ;
@@ -57,10 +61,14 @@ export class BufferDecorationRenderer extends Disposable {
5761 for ( const decoration of this . _decorationService . decorations ) {
5862 this . _renderDecoration ( decoration ) ;
5963 }
64+ this . _dimensionsChanged = false ;
6065 }
6166
6267 private _renderDecoration ( decoration : IInternalDecoration ) : void {
6368 this . _refreshStyle ( decoration ) ;
69+ if ( this . _dimensionsChanged ) {
70+ this . _refreshXPosition ( decoration ) ;
71+ }
6472 }
6573
6674 private _createElement ( decoration : IInternalDecoration ) : HTMLElement {
@@ -76,11 +84,7 @@ export class BufferDecorationRenderer extends Disposable {
7684 // exceeded the container width, so hide
7785 element . style . display = 'none' ;
7886 }
79- if ( ( decoration . options . anchor || 'left' ) === 'right' ) {
80- element . style . right = x ? `${ x * this . _renderService . dimensions . actualCellWidth } px` : '' ;
81- } else {
82- element . style . left = x ? `${ x * this . _renderService . dimensions . actualCellWidth } px` : '' ;
83- }
87+ this . _refreshXPosition ( decoration ) ;
8488
8589 return element ;
8690 }
@@ -108,6 +112,18 @@ export class BufferDecorationRenderer extends Disposable {
108112 }
109113 }
110114
115+ private _refreshXPosition ( decoration : IInternalDecoration ) : void {
116+ if ( ! decoration . element ) {
117+ return ;
118+ }
119+ const x = decoration . options . x ?? 0 ;
120+ if ( ( decoration . options . anchor || 'left' ) === 'right' ) {
121+ decoration . element . style . right = x ? `${ x * this . _renderService . dimensions . actualCellWidth } px` : '' ;
122+ } else {
123+ decoration . element . style . left = x ? `${ x * this . _renderService . dimensions . actualCellWidth } px` : '' ;
124+ }
125+ }
126+
111127 private _removeDecoration ( decoration : IInternalDecoration ) : void {
112128 this . _decorationElements . get ( decoration ) ?. remove ( ) ;
113129 this . _decorationElements . delete ( decoration ) ;
0 commit comments