Merge pull request #3088 from UziTech/patch-2
fix: fit addon proposing infinite dimensions
This commit is contained in:
@@ -59,6 +59,10 @@ export class FitAddon implements ITerminalAddon {
|
|||||||
// TODO: Remove reliance on private API
|
// TODO: Remove reliance on private API
|
||||||
const core = (this._terminal as any)._core;
|
const core = (this._terminal as any)._core;
|
||||||
|
|
||||||
|
if (core._renderService.dimensions.actualCellWidth === 0 || core._renderService.dimensions.actualCellHeight === 0) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
|
const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
|
||||||
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||||
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ describe('FitAddon', () => {
|
|||||||
page = await (await browser.newContext()).newPage();
|
page = await (await browser.newContext()).newPage();
|
||||||
await page.setViewportSize({ width, height });
|
await page.setViewportSize({ width, height });
|
||||||
await page.goto(APP);
|
await page.goto(APP);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async function(): Promise<any> {
|
||||||
|
await page.evaluate(`document.querySelector('#terminal-container').style.display=''`);
|
||||||
await openTerminal(page);
|
await openTerminal(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,6 +34,10 @@ describe('FitAddon', () => {
|
|||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(async function(): Promise<any> {
|
||||||
|
await page.evaluate(`window.term.dispose()`);
|
||||||
|
});
|
||||||
|
|
||||||
it('no terminal', async function(): Promise<any> {
|
it('no terminal', async function(): Promise<any> {
|
||||||
await page.evaluate(`window.fit = new FitAddon();`);
|
await page.evaluate(`window.fit = new FitAddon();`);
|
||||||
assert.equal(await page.evaluate(`window.fit.proposeDimensions()`), undefined);
|
assert.equal(await page.evaluate(`window.fit.proposeDimensions()`), undefined);
|
||||||
@@ -63,6 +71,15 @@ describe('FitAddon', () => {
|
|||||||
rows: 1
|
rows: 1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('hidden', async function(): Promise<any> {
|
||||||
|
await page.evaluate(`window.term.dispose()`);
|
||||||
|
await page.evaluate(`document.querySelector('#terminal-container').style.display='none'`);
|
||||||
|
await page.evaluate(`window.term = new Terminal()`);
|
||||||
|
await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`);
|
||||||
|
await loadFit();
|
||||||
|
assert.equal(await page.evaluate(`window.fit.proposeDimensions()`), undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fit', () => {
|
describe('fit', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user