Skip to content

Commit cf7f324

Browse files
authored
Add commands to toggle left and right panel (eclipse-theia#15041)
This was already implemented for the bottom panel, but missing for the left and right panel. This allows the user to add keybindings to easily show/hide all panels. Signed-off-by: Simon Graband <sgraband@eclipsesource.com>
1 parent 82a3e31 commit cf7f324

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/core/src/browser/common-frontend-contribution.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,16 @@ export namespace CommonCommands {
253253
category: VIEW_CATEGORY,
254254
label: 'Toggle Bottom Panel'
255255
}, 'theia/core/common/collapseBottomPanel', VIEW_CATEGORY_KEY);
256+
export const TOGGLE_LEFT_PANEL = Command.toLocalizedCommand({
257+
id: 'core.toggle.left.panel',
258+
category: VIEW_CATEGORY,
259+
label: 'Toggle Left Panel'
260+
}, 'theia/core/common/collapseLeftPanel', VIEW_CATEGORY_KEY);
261+
export const TOGGLE_RIGHT_PANEL = Command.toLocalizedCommand({
262+
id: 'core.toggle.right.panel',
263+
category: VIEW_CATEGORY,
264+
label: 'Toggle Right Panel'
265+
}, 'theia/core/common/collapseRightPanel', VIEW_CATEGORY_KEY);
256266
export const TOGGLE_STATUS_BAR = Command.toDefaultLocalizedCommand({
257267
id: 'workbench.action.toggleStatusbarVisibility',
258268
category: VIEW_CATEGORY,
@@ -955,6 +965,26 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
955965
}
956966
}
957967
});
968+
commandRegistry.registerCommand(CommonCommands.TOGGLE_LEFT_PANEL, {
969+
isEnabled: () => this.shell.getWidgets('left').length > 0,
970+
execute: () => {
971+
if (this.shell.isExpanded('left')) {
972+
this.shell.collapsePanel('left');
973+
} else {
974+
this.shell.expandPanel('left');
975+
}
976+
}
977+
});
978+
commandRegistry.registerCommand(CommonCommands.TOGGLE_RIGHT_PANEL, {
979+
isEnabled: () => this.shell.getWidgets('right').length > 0,
980+
execute: () => {
981+
if (this.shell.isExpanded('right')) {
982+
this.shell.collapsePanel('right');
983+
} else {
984+
this.shell.expandPanel('right');
985+
}
986+
}
987+
});
958988
commandRegistry.registerCommand(CommonCommands.TOGGLE_STATUS_BAR, {
959989
execute: () => this.preferenceService.updateValue('workbench.statusBar.visible', !this.preferences['workbench.statusBar.visible'])
960990
});

0 commit comments

Comments
 (0)