Skip to content

Commit

Permalink
fix(terminal): split-terminal visibility
Browse files Browse the repository at this point in the history
Removed the toolbar contribution from the UI.

Ref: eclipse-theia/theia#12626/
Signed-off-by: dankeboy36 <[email protected]>
  • Loading branch information
dankeboy36 authored and kittaakos committed Jul 5, 2023
1 parent 0bcb182 commit 954fee4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ import { MonacoEditorMenuContribution as TheiaMonacoEditorMenuContribution } fro
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';
import { TerminalFrontendContribution } from './theia/terminal/terminal-frontend-contribution';
import { TerminalFrontendContribution as TheiaTerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution'

// 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 @@ -1031,4 +1033,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {

// Patch terminal issues.
rebind(TerminalWidget).to(TerminalWidgetImpl).inTransientScope();
bind(TerminalFrontendContribution).toSelf().inSingletonScope();
rebind(TheiaTerminalFrontendContribution).toService(TerminalFrontendContribution);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { CommandRegistry } from '@theia/core/lib/common/command';
import { Widget } from '@theia/core/shared/@phosphor/widgets';
import { injectable } from '@theia/core/shared/inversify';
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
import {
TerminalCommands,
TerminalFrontendContribution as TheiaTerminalFrontendContribution,
} from '@theia/terminal/lib/browser/terminal-frontend-contribution';

// Patch for https://github.com/eclipse-theia/theia/pull/12626
@injectable()
export class TerminalFrontendContribution extends TheiaTerminalFrontendContribution {
override registerCommands(commands: CommandRegistry): void {
super.registerCommands(commands);
commands.unregisterCommand(TerminalCommands.SPLIT);
commands.registerCommand(TerminalCommands.SPLIT, {
execute: () => this.splitTerminal(),
isEnabled: (w) => this.withWidget(w, () => true),
isVisible: (w) => this.withWidget(w, () => true),
});
}

override registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
super.registerToolbarItems(toolbar);
toolbar.unregisterItem(TerminalCommands.SPLIT.id);
}

private withWidget<T>(
widget: Widget | undefined,
fn: (widget: TerminalWidget) => T
): T | false {
if (widget instanceof TerminalWidget) {
return fn(widget);
}
return false;
}
}

0 comments on commit 954fee4

Please sign in to comment.