Skip to content

Commit 640ea60

Browse files
committed
Action feedback
1 parent 52518bd commit 640ea60

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/browser/Viewport.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
@@ -93,14 +95,19 @@ export class Viewport extends Disposable implements IViewport {
9395
this._ignoreNextScrollEvent = true;
9496
this._viewportElement.scrollTop = scrollTop;
9597
}
96-
if (this._optionsService.getOption('scrollback') === 0) {
98+
99+
// Update scroll bar width
100+
if (this._optionsService.options.scrollback === 0) {
97101
this.scrollBarWidth = 0;
98102
} else {
99103
this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
100104
}
105+
this._lastHadScrollBar = this.scrollBarWidth > 0;
106+
101107
this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px';
102108
this._refreshAnimationFrame = null;
103109
}
110+
104111
/**
105112
* Updates dimensions and synchronizes the scroll area if necessary.
106113
*/
@@ -136,9 +143,11 @@ export class Viewport extends Disposable implements IViewport {
136143
this._refresh(immediate);
137144
return;
138145
}
139-
// This is for refreshing the viewport if scrollBarWidth has to be updated
140-
this._refresh(immediate);
141-
return;
146+
147+
// If the scroll bar visibility changed
148+
if (this._lastHadScrollBar !== (this._optionsService.options.scrollback > 0)) {
149+
this._refresh(immediate);
150+
}
142151
}
143152

144153
/**

0 commit comments

Comments
 (0)