forked from arduino/arduino-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminal-frontend-contribution.ts
38 lines (35 loc) · 1.42 KB
/
terminal-frontend-contribution.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
}
}