Skip to content

Commit ad730f2

Browse files
authored
Merge pull request #5777 from Tyler-V/fix/fit-addon-same-dimension-guard
fix(addon-fit): remove redundant same-dimension guard in fit()
2 parents 9c7c163 + 9f6c7d7 commit ad730f2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

addons/addon-fit/src/FitAddon.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ export class FitAddon implements ITerminalAddon, IFitApi {
4848
return;
4949
}
5050

51-
// Force a full render
52-
if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {
53-
this._terminal.resize(dims.cols, dims.rows);
54-
}
51+
this._terminal.resize(dims.cols, dims.rows);
5552
}
5653

5754
public proposeDimensions(): ITerminalDimensions | undefined {

addons/addon-fit/test/FitAddon.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ test.describe('FitAddon', () => {
119119
strictEqual(await ctx.proxy.cols, 2);
120120
strictEqual(await ctx.proxy.rows, 1);
121121
});
122+
123+
test('same dimensions', async function(): Promise<any> {
124+
await setDimensions();
125+
await ctx.page.evaluate(`window.fit.fit()`);
126+
const cols: number = await ctx.proxy.cols;
127+
const rows: number = await ctx.proxy.rows;
128+
// Calling fit() again at the same container size should not throw
129+
await ctx.page.evaluate(`window.fit.fit()`);
130+
strictEqual(await ctx.proxy.cols, cols);
131+
strictEqual(await ctx.proxy.rows, rows);
132+
});
122133
});
123134
});
124135

0 commit comments

Comments
 (0)