Skip to content

Commit e5ec7d2

Browse files
authored
Toggle Editor Actions in Titlebar when Tab Bar is Hidden (#198494)
* Toggle Editor Actions in Titlebar when tab bar is hidden
1 parent d704c62 commit e5ec7d2

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { EventType, EventHelper, Dimension, append, $, addDisposableListener, pr
2323
import { CustomMenubarControl } from 'vs/workbench/browser/parts/titlebar/menubarControl';
2424
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
2525
import { Emitter, Event } from 'vs/base/common/event';
26-
import { IStorageService } from 'vs/platform/storage/common/storage';
26+
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
2727
import { Parts, IWorkbenchLayoutService, ActivityBarPosition, LayoutSettings } from 'vs/workbench/services/layout/browser/layoutService';
2828
import { createActionViewItem, createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
2929
import { Action2, IMenu, IMenuService, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
@@ -609,7 +609,7 @@ export class TitlebarPart extends Part implements ITitleService {
609609
}
610610

611611

612-
class ToogleConfigAction extends Action2 {
612+
class ToggleConfigAction extends Action2 {
613613

614614
constructor(private readonly section: string, title: string, order: number) {
615615
super({
@@ -627,18 +627,43 @@ class ToogleConfigAction extends Action2 {
627627
}
628628
}
629629

630-
registerAction2(class ToogleCommandCenter extends ToogleConfigAction {
630+
registerAction2(class ToggleCommandCenter extends ToggleConfigAction {
631631
constructor() {
632632
super(LayoutSettings.COMMAND_CENTER, localize('toggle.commandCenter', 'Command Center'), 1);
633633
}
634634
});
635635

636-
registerAction2(class ToogleLayoutControl extends ToogleConfigAction {
636+
registerAction2(class ToggleLayoutControl extends ToggleConfigAction {
637637
constructor() {
638638
super('workbench.layoutControl.enabled', localize('toggle.layout', 'Layout Controls'), 2);
639639
}
640640
});
641641

642+
registerAction2(class ToggleEditorActions extends Action2 {
643+
static readonly settingsID = `workbench.editor.editorActionsLocation`;
644+
constructor() {
645+
super({
646+
id: `toggle.${ToggleEditorActions.settingsID}`,
647+
title: localize('toggle.editorActions', 'Editor Actions'),
648+
toggled: ContextKeyExpr.equals(`config.${ToggleEditorActions.settingsID}`, 'hidden').negate(),
649+
menu: { id: MenuId.TitleBarContext, order: 3, when: ContextKeyExpr.equals(`config.workbench.editor.showTabs`, 'none') }
650+
});
651+
}
652+
653+
run(accessor: ServicesAccessor, ...args: any[]): void {
654+
const configService = accessor.get(IConfigurationService);
655+
const storageService = accessor.get(IStorageService);
656+
const value = configService.getValue<string>(ToggleEditorActions.settingsID);
657+
if (value === 'hidden') {
658+
const storedValue = storageService.get(ToggleEditorActions.settingsID, StorageScope.PROFILE);
659+
configService.updateValue(ToggleEditorActions.settingsID, storedValue ?? 'default');
660+
} else {
661+
configService.updateValue(ToggleEditorActions.settingsID, 'hidden');
662+
storageService.store(ToggleEditorActions.settingsID, value, StorageScope.PROFILE, StorageTarget.USER);
663+
}
664+
}
665+
});
666+
642667
const ACCOUNTS_ACTIVITY_TILE_ACTION: IAction = {
643668
id: ACCOUNTS_ACTIVITY_ID,
644669
label: localize('accounts', "Accounts"),

0 commit comments

Comments
 (0)