forked from arduino/arduino-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(terminal):
split-terminal
visibility
Ref: eclipse-theia/theia#12626/ Signed-off-by: dankeboy36 <[email protected]>
- Loading branch information
1 parent
767cb3d
commit b36448b
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
arduino-ide-extension/src/browser/theia/terminal/terminal-frontend-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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 { | ||
TerminalFrontendContribution as TheiaTerminalFrontendContribution, | ||
TerminalCommands, | ||
} 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), | ||
}); | ||
} | ||
|
||
private withWidget<T>( | ||
widget: Widget | undefined, | ||
fn: (widget: TerminalWidget) => T | ||
): T | false { | ||
if (widget instanceof TerminalWidget) { | ||
return fn(widget); | ||
} | ||
return false; | ||
} | ||
} |