@@ -23,6 +23,7 @@ export class Viewport extends Disposable implements IViewport {
2323 private _lastRecordedBufferHeight : number = 0 ;
2424 private _lastTouchY : number = 0 ;
2525 private _lastScrollTop : number = 0 ;
26+ private _lastHadScrollBar : boolean = false ;
2627
2728 // Stores a partial line amount when scrolling, this is used to keep track of how much of a line
2829 // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a
@@ -47,6 +48,7 @@ export class Viewport extends Disposable implements IViewport {
4748 // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case,
4849 // therefore we account for a standard amount to make it visible
4950 this . scrollBarWidth = ( this . _viewportElement . offsetWidth - this . _scrollArea . offsetWidth ) || FALLBACK_SCROLL_BAR_WIDTH ;
51+ this . _lastHadScrollBar = true ;
5052 this . register ( addDisposableDomListener ( this . _viewportElement , 'scroll' , this . _onScroll . bind ( this ) ) ) ;
5153
5254 // Perform this async to ensure the ICharSizeService is ready.
@@ -94,8 +96,18 @@ export class Viewport extends Disposable implements IViewport {
9496 this . _viewportElement . scrollTop = scrollTop ;
9597 }
9698
99+ // Update scroll bar width
100+ if ( this . _optionsService . options . scrollback === 0 ) {
101+ this . scrollBarWidth = 0 ;
102+ } else {
103+ this . scrollBarWidth = ( this . _viewportElement . offsetWidth - this . _scrollArea . offsetWidth ) || FALLBACK_SCROLL_BAR_WIDTH ;
104+ }
105+ this . _lastHadScrollBar = this . scrollBarWidth > 0 ;
106+
107+ this . _viewportElement . style . width = ( this . _renderService . dimensions . actualCellWidth * ( this . _bufferService . cols ) + this . scrollBarWidth ) . toString ( ) + 'px' ;
97108 this . _refreshAnimationFrame = null ;
98109 }
110+
99111 /**
100112 * Updates dimensions and synchronizes the scroll area if necessary.
101113 */
@@ -131,6 +143,11 @@ export class Viewport extends Disposable implements IViewport {
131143 this . _refresh ( immediate ) ;
132144 return ;
133145 }
146+
147+ // If the scroll bar visibility changed
148+ if ( this . _lastHadScrollBar !== ( this . _optionsService . options . scrollback > 0 ) ) {
149+ this . _refresh ( immediate ) ;
150+ }
134151 }
135152
136153 /**
0 commit comments