diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index 6280deda0e5..a7fbb7cd2b5 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -45,7 +45,6 @@ const CHANGE_CELL_TO_MARKDOWN_COMMAND_ID = 'notebook.cell.changeToMarkdown'; const EDIT_CELL_COMMAND_ID = 'notebook.cell.edit'; const QUIT_EDIT_CELL_COMMAND_ID = 'notebook.cell.quitEdit'; -const SAVE_CELL_COMMAND_ID = 'notebook.cell.save'; const DELETE_CELL_COMMAND_ID = 'notebook.cell.delete'; const MOVE_CELL_UP_COMMAND_ID = 'notebook.cell.moveUp'; @@ -324,30 +323,6 @@ registerAction2(class extends NotebookAction { } }); -registerAction2(class extends NotebookAction { - constructor() { - super({ - id: QUIT_EDIT_CELL_COMMAND_ID, - title: localize('notebookActions.quitEditing', "Quit Notebook Cell Editing"), - category: NOTEBOOK_ACTIONS_CATEGORY, - keybinding: { - when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, InputFocusedContext, EditorContextKeys.hoverVisible.toNegated()), - primary: KeyCode.Escape, - weight: EDITOR_WIDGET_ACTION_WEIGHT - 5 - }, - precondition: NOTEBOOK_IS_ACTIVE_EDITOR, - }); - } - - async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise { - if (context.cell.cellKind === CellKind.Markdown) { - context.cell.editState = CellEditState.Preview; - } - - await context.notebookEditor.focusNotebookCell(context.cell, 'container'); - } -}); - MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: EXECUTE_NOTEBOOK_COMMAND_ID, @@ -626,7 +601,7 @@ registerAction2(class extends NotebookAction { } async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise { - context.notebookEditor.editNotebookCell(context.cell); + context.notebookEditor.focusNotebookCell(context.cell, 'editor'); } }); @@ -634,8 +609,8 @@ registerAction2(class extends NotebookAction { constructor() { super( { - id: SAVE_CELL_COMMAND_ID, - title: localize('notebookActions.saveCell', "Save Cell"), + id: QUIT_EDIT_CELL_COMMAND_ID, + title: localize('notebookActions.quitEdit', "Stop Editing Cell"), menu: { id: MenuId.NotebookCellTitle, when: ContextKeyExpr.and( @@ -644,12 +619,24 @@ registerAction2(class extends NotebookAction { NOTEBOOK_CELL_EDITABLE), order: CellToolbarOrder.SaveCell }, - icon: { id: 'codicon/check' } + icon: { id: 'codicon/check' }, + keybinding: { + when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, InputFocusedContext, EditorContextKeys.hoverVisible.toNegated()), + primary: KeyCode.Escape, + weight: EDITOR_WIDGET_ACTION_WEIGHT - 5 + }, + category: NOTEBOOK_ACTIONS_CATEGORY, + precondition: NOTEBOOK_IS_ACTIVE_EDITOR, + f1: true }); } async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext) { - return context.notebookEditor.saveNotebookCell(context.cell); + if (context.cell.cellKind === CellKind.Markdown) { + context.cell.editState = CellEditState.Preview; + } + + return context.notebookEditor.focusNotebookCell(context.cell, 'container'); } }); diff --git a/src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts b/src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts index 0a6cb18fab2..af013a546f0 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts @@ -219,19 +219,6 @@ export interface INotebookEditor extends IEditor { */ moveCell(cell: ICellViewModel, relativeToCell: ICellViewModel, direction: 'above' | 'below'): Promise; - /** - * Switch the cell into editing mode. - * - * For code cell, the monaco editor will be focused. - * For markdown cell, it will switch from preview mode to editing mode, which focuses the monaco editor. - */ - editNotebookCell(cell: ICellViewModel): void; - - /** - * Quit cell editing mode. - */ - saveNotebookCell(cell: ICellViewModel): void; - /** * Focus the container of a cell (the monaco editor inside is not focused). */ diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index c11b9e0dd62..9ae42d143f0 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -1091,10 +1091,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor this.renderedEditors.get(cell)?.focus(); } - saveNotebookCell(cell: ICellViewModel): void { - cell.editState = CellEditState.Preview; - } - getActiveCell() { let elements = this.list?.getFocusedElements(); diff --git a/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts b/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts index f979e6ac246..67f201df86d 100644 --- a/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts @@ -184,12 +184,6 @@ export class TestNotebookEditor implements INotebookEditor { deleteNotebookCell(cell: CellViewModel): Promise { throw new Error('Method not implemented.'); } - editNotebookCell(cell: CellViewModel): void { - // throw new Error('Method not implemented.'); - } - saveNotebookCell(cell: CellViewModel): void { - // throw new Error('Method not implemented.'); - } focusNotebookCell(cell: CellViewModel, focusItem: 'editor' | 'container' | 'output'): void { // throw new Error('Method not implemented.'); }