From db521cdfdb5a7a80d88d37d118575f92cdb7d546 Mon Sep 17 00:00:00 2001 From: Jonah Iden Date: Wed, 3 Apr 2024 17:04:50 +0200 Subject: [PATCH 1/3] add shift enter also for markdown cells Signed-off-by: Jonah Iden --- .../contributions/notebook-cell-actions-contribution.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts b/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts index 0481b4bd6f6ba..cae05a9e8d9b1 100644 --- a/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts +++ b/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts @@ -259,12 +259,14 @@ export class NotebookCellActionContribution implements MenuContribution, Command commands.registerCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_AND_FOCUS_NEXT_COMMAND, this.editableCellCommandHandler( (notebookModel, cell) => { - commands.executeCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_COMMAND.id, notebookModel, cell); + if (cell.cellKind === CellKind.Code) { + commands.executeCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_COMMAND.id, notebookModel, cell); + } const index = notebookModel.cells.indexOf(cell); if (index < notebookModel.cells.length - 1) { notebookModel.setSelectedCell(notebookModel.cells[index + 1]); } else { - commands.executeCommand(NotebookCellCommands.INSERT_NEW_CELL_BELOW_COMMAND.id, notebookModel, CellKind.Code, 'below'); + commands.executeCommand(NotebookCellCommands.INSERT_NEW_CELL_BELOW_COMMAND.id, notebookModel, cell.cellKind, 'below'); } }) ); @@ -353,7 +355,7 @@ export class NotebookCellActionContribution implements MenuContribution, Command { command: NotebookCellCommands.EXECUTE_SINGLE_CELL_AND_FOCUS_NEXT_COMMAND.id, keybinding: KeyCode.createKeyCode({ first: Key.ENTER, modifiers: [KeyModifier.Shift] }).toString(), - when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED} && ${NOTEBOOK_CELL_TYPE} == 'code'`, + when: `${NOTEBOOK_EDITOR_FOCUSED} && ${NOTEBOOK_CELL_FOCUSED}`, }, { command: NotebookCellCommands.CLEAR_OUTPUTS_COMMAND.id, From b7ce7a990c3eddfd3c656de68d87699fd6c7d353 Mon Sep 17 00:00:00 2001 From: Jonah Iden Date: Wed, 3 Apr 2024 17:08:27 +0200 Subject: [PATCH 2/3] stop edit on shift+enter Signed-off-by: Jonah Iden --- .../browser/contributions/notebook-cell-actions-contribution.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts b/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts index cae05a9e8d9b1..a0a6951222476 100644 --- a/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts +++ b/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts @@ -261,6 +261,8 @@ export class NotebookCellActionContribution implements MenuContribution, Command (notebookModel, cell) => { if (cell.cellKind === CellKind.Code) { commands.executeCommand(NotebookCellCommands.EXECUTE_SINGLE_CELL_COMMAND.id, notebookModel, cell); + } else { + commands.executeCommand(NotebookCellCommands.STOP_EDIT_COMMAND.id, notebookModel, cell); } const index = notebookModel.cells.indexOf(cell); if (index < notebookModel.cells.length - 1) { From eebdf8b9f612c4caa22b0ad0a6a37de9a9195a50 Mon Sep 17 00:00:00 2001 From: Jonah Iden Date: Thu, 4 Apr 2024 08:54:33 +0200 Subject: [PATCH 3/3] shift+enter insert cell of same kind below Signed-off-by: Jonah Iden --- .../contributions/notebook-cell-actions-contribution.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts b/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts index a0a6951222476..37766a87c0bb5 100644 --- a/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts +++ b/packages/notebook/src/browser/contributions/notebook-cell-actions-contribution.ts @@ -267,8 +267,10 @@ export class NotebookCellActionContribution implements MenuContribution, Command const index = notebookModel.cells.indexOf(cell); if (index < notebookModel.cells.length - 1) { notebookModel.setSelectedCell(notebookModel.cells[index + 1]); + } else if (cell.cellKind === CellKind.Code) { + commands.executeCommand(NotebookCellCommands.INSERT_NEW_CELL_BELOW_COMMAND.id); } else { - commands.executeCommand(NotebookCellCommands.INSERT_NEW_CELL_BELOW_COMMAND.id, notebookModel, cell.cellKind, 'below'); + commands.executeCommand(NotebookCellCommands.INSERT_MARKDOWN_CELL_BELOW_COMMAND.id); } }) );