Merge pull request #542 from Tyriar/539_fix_initial_viewport_sync
Perform initial viewport sync after CharMeasure is ready
This commit is contained in:
+26
-18
@@ -41,13 +41,17 @@ describe('Viewport', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('refresh', () => {
|
describe('refresh', () => {
|
||||||
it('should set the line-height of the terminal', () => {
|
it('should set the line-height of the terminal', done => {
|
||||||
assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
|
// Allow CharMeasure to be initialized
|
||||||
assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
|
setTimeout(() => {
|
||||||
charMeasure.height = 1;
|
assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
|
||||||
viewport.refresh();
|
assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
|
||||||
assert.equal(viewportElement.style.lineHeight, '1px');
|
charMeasure.height = 1;
|
||||||
assert.equal(terminal.rowContainer.style.lineHeight, '1px');
|
viewport.refresh();
|
||||||
|
assert.equal(viewportElement.style.lineHeight, '1px');
|
||||||
|
assert.equal(terminal.rowContainer.style.lineHeight, '1px');
|
||||||
|
done();
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
it('should set the height of the viewport when the line-height changed', () => {
|
it('should set the height of the viewport when the line-height changed', () => {
|
||||||
terminal.lines.push('');
|
terminal.lines.push('');
|
||||||
@@ -62,17 +66,21 @@ describe('Viewport', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('syncScrollArea', () => {
|
describe('syncScrollArea', () => {
|
||||||
it('should sync the scroll area', () => {
|
it('should sync the scroll area', done => {
|
||||||
terminal.lines.push('');
|
// Allow CharMeasure to be initialized
|
||||||
terminal.rows = 1;
|
setTimeout(() => {
|
||||||
assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
|
terminal.lines.push('');
|
||||||
viewport.syncScrollArea();
|
terminal.rows = 1;
|
||||||
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
|
assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
|
||||||
assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
|
viewport.syncScrollArea();
|
||||||
terminal.lines.push('');
|
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
|
||||||
viewport.syncScrollArea();
|
assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
|
||||||
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
|
terminal.lines.push('');
|
||||||
assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
|
viewport.syncScrollArea();
|
||||||
|
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
|
||||||
|
assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
|
||||||
|
done();
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-1
@@ -35,7 +35,8 @@ export class Viewport {
|
|||||||
this.terminal.on('resize', this.syncScrollArea.bind(this));
|
this.terminal.on('resize', this.syncScrollArea.bind(this));
|
||||||
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
|
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
|
||||||
|
|
||||||
this.syncScrollArea();
|
// Perform this async to ensure the CharMeasure is ready.
|
||||||
|
setTimeout(() => this.syncScrollArea(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user