Skip to content

Commit 954fee4

Browse files
dankeboy36kittaakos
authored andcommitted
fix(terminal): split-terminal visibility
Removed the toolbar contribution from the UI. Ref: eclipse-theia/theia#12626/ Signed-off-by: dankeboy36 <dankeboy36@gmail.com>
1 parent 0bcb182 commit 954fee4

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+4
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ import { MonacoEditorMenuContribution as TheiaMonacoEditorMenuContribution } fro
357357
import { UpdateArduinoState } from './contributions/update-arduino-state';
358358
import { TerminalWidgetImpl } from './theia/terminal/terminal-widget-impl';
359359
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
360+
import { TerminalFrontendContribution } from './theia/terminal/terminal-frontend-contribution';
361+
import { TerminalFrontendContribution as TheiaTerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution'
360362

361363
// Hack to fix copy/cut/paste issue after electron version update in Theia.
362364
// https://github.com/eclipse-theia/theia/issues/12487
@@ -1031,4 +1033,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
10311033

10321034
// Patch terminal issues.
10331035
rebind(TerminalWidget).to(TerminalWidgetImpl).inTransientScope();
1036+
bind(TerminalFrontendContribution).toSelf().inSingletonScope();
1037+
rebind(TheiaTerminalFrontendContribution).toService(TerminalFrontendContribution);
10341038
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
2+
import { CommandRegistry } from '@theia/core/lib/common/command';
3+
import { Widget } from '@theia/core/shared/@phosphor/widgets';
4+
import { injectable } from '@theia/core/shared/inversify';
5+
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
6+
import {
7+
TerminalCommands,
8+
TerminalFrontendContribution as TheiaTerminalFrontendContribution,
9+
} from '@theia/terminal/lib/browser/terminal-frontend-contribution';
10+
11+
// Patch for https://github.com/eclipse-theia/theia/pull/12626
12+
@injectable()
13+
export class TerminalFrontendContribution extends TheiaTerminalFrontendContribution {
14+
override registerCommands(commands: CommandRegistry): void {
15+
super.registerCommands(commands);
16+
commands.unregisterCommand(TerminalCommands.SPLIT);
17+
commands.registerCommand(TerminalCommands.SPLIT, {
18+
execute: () => this.splitTerminal(),
19+
isEnabled: (w) => this.withWidget(w, () => true),
20+
isVisible: (w) => this.withWidget(w, () => true),
21+
});
22+
}
23+
24+
override registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
25+
super.registerToolbarItems(toolbar);
26+
toolbar.unregisterItem(TerminalCommands.SPLIT.id);
27+
}
28+
29+
private withWidget<T>(
30+
widget: Widget | undefined,
31+
fn: (widget: TerminalWidget) => T
32+
): T | false {
33+
if (widget instanceof TerminalWidget) {
34+
return fn(widget);
35+
}
36+
return false;
37+
}
38+
}

0 commit comments

Comments
 (0)