Skip to content

Commit

Permalink
add shift enter also for markdown cells (#13563)
Browse files Browse the repository at this point in the history
* add shift enter also for markdown cells

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>

* stop edit on shift+enter

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>

* shift+enter insert cell of same kind below

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>

---------

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
  • Loading branch information
jonah-iden authored Apr 4, 2024
1 parent 5d653b2 commit 35a340b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,18 @@ 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);
} else {
commands.executeCommand(NotebookCellCommands.STOP_EDIT_COMMAND.id, notebookModel, cell);
}
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, CellKind.Code, 'below');
commands.executeCommand(NotebookCellCommands.INSERT_MARKDOWN_CELL_BELOW_COMMAND.id);
}
})
);
Expand Down Expand Up @@ -353,7 +359,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,
Expand Down

0 comments on commit 35a340b

Please sign in to comment.