+11
-10
@@ -34,8 +34,6 @@ export class Viewport implements IViewport {
|
||||
this.lastRecordedBufferLength = 0;
|
||||
this.lastRecordedViewportHeight = 0;
|
||||
|
||||
this.terminal.on('scroll', this.syncScrollArea.bind(this));
|
||||
this.terminal.on('resize', this.syncScrollArea.bind(this));
|
||||
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
|
||||
|
||||
// Perform this async to ensure the CharMeasure is ready.
|
||||
@@ -52,18 +50,20 @@ export class Viewport implements IViewport {
|
||||
*/
|
||||
private refresh(): void {
|
||||
if (this.charMeasure.height > 0) {
|
||||
const lineHeight = Math.ceil(this.charMeasure.height * this.terminal.options.lineHeight);
|
||||
const lineHeight = (<any>this.terminal).renderer.dimensions.scaledLineHeight / window.devicePixelRatio;
|
||||
const rowHeightChanged = lineHeight !== this.currentRowHeight;
|
||||
// TODO: Do we need lineHeight anymore??
|
||||
if (rowHeightChanged) {
|
||||
this.currentRowHeight = lineHeight;
|
||||
this.viewportElement.style.lineHeight = lineHeight + 'px';
|
||||
}
|
||||
const viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.rows;
|
||||
if (rowHeightChanged || viewportHeightChanged) {
|
||||
this.lastRecordedViewportHeight = this.terminal.rows;
|
||||
this.viewportElement.style.height = lineHeight * this.terminal.rows + 'px';
|
||||
// const viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.rows;
|
||||
const viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight;
|
||||
if (viewportHeightChanged) {
|
||||
this.lastRecordedViewportHeight = this.terminal.renderer.dimensions.canvasHeight;
|
||||
this.viewportElement.style.height = this.lastRecordedViewportHeight + 'px';
|
||||
}
|
||||
this.scrollArea.style.height = (lineHeight * this.lastRecordedBufferLength) + 'px';
|
||||
this.scrollArea.style.height = Math.round(lineHeight * this.lastRecordedBufferLength) + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +75,13 @@ export class Viewport implements IViewport {
|
||||
// If buffer height changed
|
||||
this.lastRecordedBufferLength = this.terminal.buffer.lines.length;
|
||||
this.refresh();
|
||||
} else if (this.lastRecordedViewportHeight !== this.terminal.rows) {
|
||||
} else if (this.lastRecordedViewportHeight !== (<any>this.terminal).renderer.dimensions.canvasHeight) {
|
||||
// If viewport height changed
|
||||
this.refresh();
|
||||
} else {
|
||||
// If size has changed, refresh viewport
|
||||
if (Math.ceil(this.charMeasure.height * this.terminal.options.lineHeight) !== this.currentRowHeight) {
|
||||
console.log(this.terminal.renderer.dimensions.scaledLineHeight / window.devicePixelRatio);
|
||||
if (this.terminal.renderer.dimensions.scaledLineHeight / window.devicePixelRatio !== this.currentRowHeight) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user