Skip to content

Commit

Permalink
fix(terminal): widget flickering on resize
Browse files Browse the repository at this point in the history
Ref: eclipse-theia/theia#12587
Signed-off-by: dankeboy36 <dankeboy36@gmail.com>
  • Loading branch information
dankeboy36 committed Jun 27, 2023
1 parent 4d79caa commit 767cb3d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ import { StylingParticipant } from '@theia/core/lib/browser/styling-service';
import { MonacoEditorMenuContribution } from './theia/monaco/monaco-menu';
import { MonacoEditorMenuContribution as TheiaMonacoEditorMenuContribution } from '@theia/monaco/lib/browser/monaco-menu';
import { UpdateArduinoState } from './contributions/update-arduino-state';
import { TerminalWidgetImpl } from './theia/terminal/terminal-widget-impl';
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';

// Hack to fix copy/cut/paste issue after electron version update in Theia.
// https://github.com/eclipse-theia/theia/issues/12487
Expand Down Expand Up @@ -1026,4 +1028,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
rebind(TheiaMonacoEditorMenuContribution).toService(
MonacoEditorMenuContribution
);

// Patch terminal issues.
rebind(TerminalWidget).to(TerminalWidgetImpl).inTransientScope();
});
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 767cb3d

Please sign in to comment.