Skip to content

Commit

Permalink
Create refresh scroll bar method, increase scroll padding
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Nov 5, 2021
1 parent 9419cdc commit f2fa859
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1621,11 +1621,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
return;
}
this._fixedRows = this._parseFixedDimension(rows);
if (this._fixedRows || this._fixedCols) {
this._addScrollbar();
} else {
this._removeScrollbar();
}
this._labelComputer?.refreshLabel();
await this._refreshScrollbar();
this._resize();
this.focus();
}
Expand All @@ -1650,7 +1647,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._fixedCols = undefined;
this._fixedRows = undefined;
this._hasScrollBar = false;
await this._removeScrollbar();
this._initDimensions();
await this._resize();
} else {
Expand All @@ -1669,13 +1665,20 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// bar look bad being off the edge
if (proposedCols > this.xterm.raw.cols) {
this._fixedCols = proposedCols;
await this._addScrollbar();
}
}
await this._refreshScrollbar();
this._labelComputer?.refreshLabel();
this.focus();
}

private _refreshScrollbar(): Promise<void> {
if (this._fixedCols || this._fixedRows) {
return this._addScrollbar();
}
return this._removeScrollbar();
}

private async _addScrollbar(): Promise<void> {
const charWidth = (this.xterm ? this.xterm.getFont() : this._configHelper.getFont()).charWidth;
if (!this.xterm?.raw.element || !this._wrapperElement || !this._container || !charWidth || !this._fixedCols) {
Expand All @@ -1701,7 +1704,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._horizontalScrollbar.setScrollDimensions({
width: this.xterm.raw.element.clientWidth,
// TODO: Use const/property for padding
scrollWidth: this._fixedCols * charWidth + 30
scrollWidth: this._fixedCols * charWidth + 40
});
this._horizontalScrollbar.getDomNode().style.paddingBottom = '16px';

Expand All @@ -1713,11 +1716,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}

private async _removeScrollbar(): Promise<void> {
if (!this._container || !this._wrapperElement) {
if (!this._container || !this._wrapperElement || !this._horizontalScrollbar) {
return;
}
this._horizontalScrollbar?.getDomNode().remove();
this._horizontalScrollbar?.dispose();
this._horizontalScrollbar.getDomNode().remove();
this._horizontalScrollbar.dispose();
this._horizontalScrollbar = undefined;
this._wrapperElement.remove();
this._wrapperElement.classList.remove('fixed-dims');
Expand Down

0 comments on commit f2fa859

Please sign in to comment.