Skip to content

Commit b36448b

Browse files
committed
fix(terminal): split-terminal visibility
Ref: eclipse-theia/theia#12626/ Signed-off-by: dankeboy36 <[email protected]>
1 parent 767cb3d commit b36448b

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-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,32 @@
1+
import { CommandRegistry } from '@theia/core/lib/common/command';
2+
import { Widget } from '@theia/core/shared/@phosphor/widgets';
3+
import { injectable } from '@theia/core/shared/inversify';
4+
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
5+
import {
6+
TerminalFrontendContribution as TheiaTerminalFrontendContribution,
7+
TerminalCommands,
8+
} from '@theia/terminal/lib/browser/terminal-frontend-contribution';
9+
10+
// Patch for https://github.com/eclipse-theia/theia/pull/12626
11+
@injectable()
12+
export class TerminalFrontendContribution extends TheiaTerminalFrontendContribution {
13+
override registerCommands(commands: CommandRegistry): void {
14+
super.registerCommands(commands);
15+
commands.unregisterCommand(TerminalCommands.SPLIT);
16+
commands.registerCommand(TerminalCommands.SPLIT, {
17+
execute: () => this.splitTerminal(),
18+
isEnabled: (w) => this.withWidget(w, () => true),
19+
isVisible: (w) => this.withWidget(w, () => true),
20+
});
21+
}
22+
23+
private withWidget<T>(
24+
widget: Widget | undefined,
25+
fn: (widget: TerminalWidget) => T
26+
): T | false {
27+
if (widget instanceof TerminalWidget) {
28+
return fn(widget);
29+
}
30+
return false;
31+
}
32+
}

0 commit comments

Comments
 (0)