From dab73aa26355d8897968bffe3fc3366c2ca80a28 Mon Sep 17 00:00:00 2001 From: Puneethnaik Date: Wed, 28 Jul 2021 15:56:26 +0000 Subject: [PATCH 1/2] update the viewportElement style width upon refreshing of the viewport to accomodate changes in scrollBarWidth --- demo/client.ts | 3 +++ src/browser/Viewport.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/demo/client.ts b/demo/client.ts index 0bb124cd..7b675520 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -348,6 +348,9 @@ function initOptions(term: TerminalType): void { } else if (o === 'lineHeight' || o === 'scrollSensitivity') { term.setOption(o, parseFloat(input.value)); updateTerminalSize(); + } else if(o === 'scrollback') { + term.setOption(o, parseInt(input.value)); + setTimeout(() => updateTerminalSize(), 5); } else { term.setOption(o, parseInt(input.value)); } diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 162ed174..77325ef9 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -93,7 +93,12 @@ export class Viewport extends Disposable implements IViewport { this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } - + if (this._optionsService.getOption('scrollback') === 0) { + this.scrollBarWidth = 0; + } else { + this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; + } + this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px'; this._refreshAnimationFrame = null; } /** @@ -131,6 +136,9 @@ export class Viewport extends Disposable implements IViewport { this._refresh(immediate); return; } + // This is for refreshing the viewport if scrollBarWidth has to be updated + this._refresh(immediate); + return; } /** From 640ea60945794aaadc17acc14bcc8f5673989b5d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 30 Aug 2021 10:48:12 -0700 Subject: [PATCH 2/2] Action feedback --- src/browser/Viewport.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 77325ef9..9ce14daf 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -23,6 +23,7 @@ export class Viewport extends Disposable implements IViewport { private _lastRecordedBufferHeight: number = 0; private _lastTouchY: number = 0; private _lastScrollTop: number = 0; + private _lastHadScrollBar: boolean = false; // Stores a partial line amount when scrolling, this is used to keep track of how much of a line // 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 { // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case, // therefore we account for a standard amount to make it visible this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; + this._lastHadScrollBar = true; this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this))); // Perform this async to ensure the ICharSizeService is ready. @@ -93,14 +95,19 @@ export class Viewport extends Disposable implements IViewport { this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } - if (this._optionsService.getOption('scrollback') === 0) { + + // Update scroll bar width + if (this._optionsService.options.scrollback === 0) { this.scrollBarWidth = 0; } else { this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; } + this._lastHadScrollBar = this.scrollBarWidth > 0; + this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px'; this._refreshAnimationFrame = null; } + /** * Updates dimensions and synchronizes the scroll area if necessary. */ @@ -136,9 +143,11 @@ export class Viewport extends Disposable implements IViewport { this._refresh(immediate); return; } - // This is for refreshing the viewport if scrollBarWidth has to be updated - this._refresh(immediate); - return; + + // If the scroll bar visibility changed + if (this._lastHadScrollBar !== (this._optionsService.options.scrollback > 0)) { + this._refresh(immediate); + } } /**