Fix several issues with line height

Fixes #966
Fixes #967
This commit is contained in:
Daniel Imms
2017-09-10 10:31:19 -07:00
parent 948eedba89
commit ae741348a6
13 changed files with 125 additions and 68 deletions
+11 -10
View File
@@ -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();
}
}