Skip to content

Commit faffd95

Browse files
authored
Remove Format Document from the Editor Action Bar (#8196)
Addresses #8189 by removing the Format Document action from the Editor Action Bar.
1 parent c5300a8 commit faffd95

File tree

2 files changed

+18
-53
lines changed

2 files changed

+18
-53
lines changed

src/vs/workbench/browser/parts/editor/editorActionBarControl.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export class EditorActionBarControl extends Disposable {
101101
// Create the editor action bar factory.
102102
const editorActionBarFactory = this._register(new EditorActionBarFactory(
103103
this._editorGroup,
104-
this._commandService,
105104
this._contextKeyService,
106105
this._keybindingService,
107106
this._menuService,

src/vs/workbench/browser/parts/editor/editorActionBarFactory.tsx

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ import { localize } from '../../../../nls.js';
1111
import { IEditorGroupView } from './editor.js';
1212
import { Emitter } from '../../../../base/common/event.js';
1313
import { ThemeIcon } from '../../../../base/common/themables.js';
14-
import { ICommandService } from '../../../../platform/commands/common/commands.js';
15-
import { EditorContextKeys } from '../../../../editor/common/editorContextKeys.js';
1614
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
1715
import { IAction, Separator, SubmenuAction } from '../../../../base/common/actions.js';
1816
import { actionTooltip } from '../../../../platform/positronActionBar/common/helpers.js';
1917
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
18+
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
2019
import { PositronActionBar } from '../../../../platform/positronActionBar/browser/positronActionBar.js';
21-
import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
2220
import { ActionBarRegion } from '../../../../platform/positronActionBar/browser/components/actionBarRegion.js';
23-
import { ActionBarButton } from '../../../../platform/positronActionBar/browser/components/actionBarButton.js';
2421
import { ActionBarSeparator } from '../../../../platform/positronActionBar/browser/components/actionBarSeparator.js';
2522
import { ActionBarMenuButton } from '../../../../platform/positronActionBar/browser/components/actionBarMenuButton.js';
2623
import { ActionBarActionButton } from '../../../../platform/positronActionBar/browser/components/actionBarActionButton.js';
@@ -37,14 +34,6 @@ const PADDING_RIGHT = 8;
3734
/**
3835
* Localized strings.
3936
*/
40-
const positronFormatDocumentAriaLabel = localize(
41-
'positronFormatDocumentAriaLabel',
42-
"Format Document"
43-
);
44-
const positronFormatDocumentTooltip = localize(
45-
'positronFormatDocumentTooltip',
46-
"Format Document"
47-
);
4837
const positronMoveIntoNewWindowAriaLabel = localize(
4938
'positronMoveIntoNewWindowAriaLabel',
5039
"Move into new window"
@@ -77,15 +66,6 @@ interface SubmenuDescriptor {
7766
export class EditorActionBarFactory extends Disposable {
7867
//#region Private Properties
7968

80-
/**
81-
* The context key expression for showing the format document action.
82-
*/
83-
private readonly _showFormatDocumentContextKeyExpr = ContextKeyExpr.and(
84-
EditorContextKeys.notInCompositeEditor,
85-
EditorContextKeys.writable,
86-
EditorContextKeys.hasDocumentFormattingProvider
87-
);
88-
8969
/**
9070
* Gets the menu disposable stores.
9171
*/
@@ -131,14 +111,12 @@ export class EditorActionBarFactory extends Disposable {
131111
/**
132112
* Constructor.
133113
* @param _editorGroup The editor group.
134-
* @param _commandService The command service.
135114
* @param _contextKeyService The context key service.
136115
* @param _keybindingService The keybinding service.
137116
* @param _menuService The menu service.
138117
*/
139118
constructor(
140119
private readonly _editorGroup: IEditorGroupView,
141-
private readonly _commandService: ICommandService,
142120
private readonly _contextKeyService: IContextKeyService,
143121
private readonly _keybindingService: IKeybindingService,
144122
private readonly _menuService: IMenuService,
@@ -181,35 +159,23 @@ export class EditorActionBarFactory extends Disposable {
181159
// Create the set of processed actions.
182160
const processedActions = new Set<string>();
183161

184-
// Create the left action bar elements from the editor title menu's EditorTitleRun action.
185-
const leftActionBarElements = this.buildActionBarElements(
186-
processedActions,
187-
false,
188-
MenuId.EditorTitle,
189-
new Set(['submenuitem.EditorTitleRun']),
190-
);
191-
192-
// Append the format document action to the left action bar elements, if applicable.
193-
const activeEditorContextKeyService = this._editorGroup.activeEditorPane?.scopedContextKeyService;
194-
if (activeEditorContextKeyService && activeEditorContextKeyService.contextMatchesRules(this._showFormatDocumentContextKeyExpr)) {
195-
leftActionBarElements.push(
196-
<ActionBarButton
197-
ariaLabel={positronFormatDocumentAriaLabel}
198-
icon={ThemeIcon.fromId('positron-format-document')}
199-
tooltip={positronFormatDocumentTooltip}
200-
onPressed={() => {
201-
this._commandService.executeCommand('editor.action.formatDocument');
202-
}}
203-
/>
204-
);
205-
}
206-
207-
// Append the editor actions left menu's EditorActionsLeft action to the left action bar elements.
208-
leftActionBarElements.push(...this.buildActionBarElements(
209-
processedActions,
210-
false,
211-
MenuId.EditorActionsLeft,
212-
));
162+
// Create the left action bar elements from the editor title menu's editor title run submenu
163+
// item and the editor actions left menu.
164+
const leftActionBarElements = [
165+
// Build action bar elements from the editor title run submenu item.
166+
...this.buildActionBarElements(
167+
processedActions,
168+
false,
169+
MenuId.EditorTitle,
170+
new Set(['submenuitem.EditorTitleRun']),
171+
),
172+
// Build action bar elements from the editor actions left menu.
173+
...this.buildActionBarElements(
174+
processedActions,
175+
false,
176+
MenuId.EditorActionsLeft,
177+
)
178+
];
213179

214180
// Build the right action bar elements from the editor actions right menu and the remaining
215181
// actions on the editor title menu.

0 commit comments

Comments
 (0)