Skip to content

Commit dab73aa

Browse files
committed
update the viewportElement style width upon refreshing of the viewport to accomodate changes in scrollBarWidth
1 parent 522c8bf commit dab73aa

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

demo/client.ts

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

src/browser/Viewport.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ export class Viewport extends Disposable implements IViewport {
9393
this._ignoreNextScrollEvent = true;
9494
this._viewportElement.scrollTop = scrollTop;
9595
}
96-
96+
if (this._optionsService.getOption('scrollback') === 0) {
97+
this.scrollBarWidth = 0;
98+
} else {
99+
this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
100+
}
101+
this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px';
97102
this._refreshAnimationFrame = null;
98103
}
99104
/**
@@ -131,6 +136,9 @@ export class Viewport extends Disposable implements IViewport {
131136
this._refresh(immediate);
132137
return;
133138
}
139+
// This is for refreshing the viewport if scrollBarWidth has to be updated
140+
this._refresh(immediate);
141+
return;
134142
}
135143

136144
/**

0 commit comments

Comments
 (0)