From 0caea2c27ae5b033751ef7cc041ec9ae953b0bc7 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Thu, 1 Jun 2023 15:18:29 +0200 Subject: [PATCH] Fix terminal widget flickering on resize (#12587) Co-authored-by: Meng Zhang --- packages/terminal/src/browser/terminal-widget-impl.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/terminal/src/browser/terminal-widget-impl.ts b/packages/terminal/src/browser/terminal-widget-impl.ts index 49e529bf08197..45d64ba7316fd 100644 --- a/packages/terminal/src/browser/terminal-widget-impl.ts +++ b/packages/terminal/src/browser/terminal-widget-impl.ts @@ -42,6 +42,7 @@ import { CommandLineOptions, ShellCommandBuilder } from '@theia/process/lib/comm import { Key } from '@theia/core/lib/browser/keys'; import { nls } from '@theia/core/lib/common/nls'; import { TerminalMenus } from './terminal-frontend-contribution'; +import debounce = require('p-debounce'); export const TERMINAL_WIDGET_FACTORY_ID = 'terminal'; @@ -758,7 +759,12 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget super.dispose(); } - protected resizeTerminal(): void { + protected resizeTerminal = debounce(() => this.doResizeTerminal(), 50); + + protected doResizeTerminal(): void { + if (this.isDisposed) { + return; + } const geo = this.fitAddon.proposeDimensions(); const cols = geo.cols; const rows = geo.rows - 1; // subtract one row for margin