Skip to content

Commit

Permalink
terminal: fix split-terminal visibility (eclipse-theia#12626)
Browse files Browse the repository at this point in the history
The commit fixes the terminal `split-terminal` toolbar item from appearing in other
views when the terminal is active.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Jun 27, 2023
1 parent 8043260 commit 507bdc8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/terminal/src/browser/terminal-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import {
ApplicationShell, KeybindingContribution, KeyCode, Key, WidgetManager, PreferenceService,
KeybindingRegistry, LabelProvider, WidgetOpenerOptions, StorageService, QuickInputService,
codicon, CommonCommands, FrontendApplicationContribution, OnWillStopAction, Dialog, ConfirmDialog, FrontendApplication, PreferenceScope
codicon, CommonCommands, FrontendApplicationContribution, OnWillStopAction, Dialog, ConfirmDialog, FrontendApplication, PreferenceScope, Widget
} from '@theia/core/lib/browser';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { TERMINAL_WIDGET_FACTORY_ID, TerminalWidgetFactoryOptions, TerminalWidgetImpl } from './terminal-widget-impl';
Expand Down Expand Up @@ -543,8 +543,8 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
});
commands.registerCommand(TerminalCommands.SPLIT, {
execute: () => this.splitTerminal(),
isEnabled: () => this.shell.currentWidget instanceof TerminalWidget,
isVisible: () => this.shell.currentWidget instanceof TerminalWidget,
isEnabled: w => this.withWidget(w, () => true),
isVisible: w => this.withWidget(w, () => true),
});
commands.registerCommand(TerminalCommands.TERMINAL_CLEAR);
commands.registerHandler(TerminalCommands.TERMINAL_CLEAR.id, {
Expand Down Expand Up @@ -1022,6 +1022,13 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
this.open(termWidget, { widgetOptions: options });
}

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

/**
* It should be aligned with https://code.visualstudio.com/api/references/theme-color#integrated-terminal-colors
*/
Expand Down

0 comments on commit 507bdc8

Please sign in to comment.