fix(terminal): widget flickering on resize

Ref: eclipse-theia/theia#12587
Signed-off-by: dankeboy36 <dankeboy36@gmail.com>
This commit is contained in:
dankeboy36
2023-06-27 17:42:49 +02:00
committed by Akos Kitta
parent 42d017e876
commit 0bcb182ec0
2 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import { injectable } from '@theia/core/shared/inversify';
import { TerminalWidgetImpl as TheiaTerminalWidgetImpl } from '@theia/terminal/lib/browser/terminal-widget-impl';
import debounce from 'p-debounce';
// Patch for https://github.com/eclipse-theia/theia/pull/12587
@injectable()
export class TerminalWidgetImpl extends TheiaTerminalWidgetImpl {
private readonly debouncedResizeTerminal = debounce(
() => this.doResizeTerminal(),
50
);
protected override resizeTerminal(): void {
this.debouncedResizeTerminal();
}
private doResizeTerminal(): void {
const geo = this.fitAddon.proposeDimensions();
const cols = geo.cols;
const rows = geo.rows - 1; // subtract one row for margin
this.term.resize(cols, rows);
}
}