Skip to content

Commit ad4e975

Browse files
committed
Force delete button to right
Fix #104082
1 parent 64d126c commit ad4e975

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ const enum CellToolbarOrder {
8787
EditCell,
8888
SplitCell,
8989
SaveCell,
90-
ClearCellOutput,
91-
DeleteCell
90+
ClearCellOutput
9291
}
9392

9493
const enum CellOverflowToolbarGroups {
@@ -261,6 +260,23 @@ export class CancelCellAction extends MenuItemAction {
261260
}
262261
}
263262

263+
export class DeleteCellAction extends MenuItemAction {
264+
constructor(
265+
@IContextKeyService contextKeyService: IContextKeyService,
266+
@ICommandService commandService: ICommandService
267+
) {
268+
super(
269+
{
270+
id: DELETE_CELL_COMMAND_ID,
271+
title: localize('notebookActions.deleteCell', "Delete Cell"),
272+
icon: { id: 'codicon/trash' }
273+
},
274+
undefined,
275+
{ shouldForwardArgs: true },
276+
contextKeyService,
277+
commandService);
278+
}
279+
}
264280

265281
registerAction2(class extends NotebookCellAction {
266282
constructor() {
@@ -775,9 +791,7 @@ registerAction2(class extends NotebookCellAction {
775791
title: localize('notebookActions.deleteCell', "Delete Cell"),
776792
menu: {
777793
id: MenuId.NotebookCellTitle,
778-
order: CellToolbarOrder.DeleteCell,
779-
when: NOTEBOOK_EDITOR_EDITABLE,
780-
group: CELL_TITLE_CELL_GROUP_ID
794+
when: NOTEBOOK_EDITOR_EDITABLE
781795
},
782796
keybinding: {
783797
primary: KeyCode.Delete,

src/vs/workbench/contrib/notebook/browser/media/notebook.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291

292292
.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-title-toolbar {
293293
visibility: hidden;
294-
display: inline-block;
294+
display: inline-flex;
295295
position: absolute;
296296
height: 26px;
297297
right: 44px;

src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
3636
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3737
import { INotificationService } from 'vs/platform/notification/common/notification';
3838
import { BOTTOM_CELL_TOOLBAR_HEIGHT, CELL_BOTTOM_MARGIN, CELL_TOP_MARGIN, EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
39-
import { CancelCellAction, ExecuteCellAction, INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/contrib/coreActions';
39+
import { CancelCellAction, DeleteCellAction, ExecuteCellAction, INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/contrib/coreActions';
4040
import { BaseCellRenderTemplate, CellEditState, CodeCellRenderTemplate, EXPAND_CELL_CONTENT_COMMAND_ID, ICellViewModel, INotebookEditor, isCodeCellRenderTemplate, MarkdownCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
4141
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys';
4242
import { CellMenus } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellMenus';
@@ -379,7 +379,12 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
379379
const container = DOM.append(rootContainer, DOM.$('.cell-inner-container'));
380380
const disposables = new DisposableStore();
381381
const contextKeyService = disposables.add(this.contextKeyServiceProvider(container));
382-
const toolbar = disposables.add(this.createToolbar(container, 'cell-title-toolbar'));
382+
383+
const titleToolbarContainer = DOM.append(container, $('.cell-title-toolbar'));
384+
const toolbar = disposables.add(this.createToolbar(titleToolbarContainer));
385+
const deleteToolbar = disposables.add(this.createToolbar(titleToolbarContainer, 'cell-delete-toolbar'));
386+
deleteToolbar.setActions([this.instantiationService.createInstance(DeleteCellAction)]);
387+
383388
const focusIndicatorLeft = DOM.append(container, DOM.$('.cell-focus-indicator.cell-focus-indicator-side.cell-focus-indicator-left'));
384389

385390
const codeInnerContent = DOM.append(container, $('.cell.code'));
@@ -644,14 +649,17 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
644649
const contextKeyService = disposables.add(this.contextKeyServiceProvider(container));
645650

646651
DOM.append(container, $('.cell-focus-indicator.cell-focus-indicator-top'));
647-
const toolbar = disposables.add(this.createToolbar(container, 'cell-title-toolbar'));
652+
const titleToolbarContainer = DOM.append(container, $('.cell-title-toolbar'));
653+
const toolbar = disposables.add(this.createToolbar(titleToolbarContainer));
654+
const deleteToolbar = disposables.add(this.createToolbar(titleToolbarContainer, 'cell-delete-toolbar'));
655+
deleteToolbar.setActions([this.instantiationService.createInstance(DeleteCellAction)]);
656+
648657
const focusIndicator = DOM.append(container, DOM.$('.cell-focus-indicator.cell-focus-indicator-side.cell-focus-indicator-left'));
649658
const dragHandle = DOM.append(container, DOM.$('.cell-drag-handle'));
650659

651660
const cellContainer = DOM.append(container, $('.cell.code'));
652661
const runButtonContainer = DOM.append(cellContainer, $('.run-button-container'));
653-
const runToolbar = this.createToolbar(runButtonContainer);
654-
disposables.add(runToolbar);
662+
const runToolbar = disposables.add(this.createToolbar(runButtonContainer));
655663

656664
const executionOrderLabel = DOM.append(runButtonContainer, $('div.execution-count-label'));
657665

0 commit comments

Comments
 (0)