Skip to content

Commit 7068954

Browse files
authored
Merge pull request #3398 from Puneethnaik/issue_3074_fix
A way to turn off the scrollbar #3074
2 parents fb43ff7 + 640ea60 commit 7068954

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

demo/client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ function initOptions(term: TerminalType): void {
349349
} else if (o === 'lineHeight' || o === 'scrollSensitivity') {
350350
term.setOption(o, parseFloat(input.value));
351351
updateTerminalSize();
352+
} else if(o === 'scrollback') {
353+
term.setOption(o, parseInt(input.value));
354+
setTimeout(() => updateTerminalSize(), 5);
352355
} else {
353356
term.setOption(o, parseInt(input.value));
354357
}

src/browser/Viewport.ts

Lines changed: 17 additions & 0 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.
@@ -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

Comments
 (0)