Skip to content

Commit

Permalink
Ctrl+Enter should put cell into command mode after executing (#6231)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl committed Jun 11, 2021
1 parent e052f2e commit e80d967
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/2 Fixes/6198.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In preview native notebooks interface, contribute `ctrl+enter` keybinding which puts the current cell into control mode instead of leaving it in edit mode after running.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
{
"key": "ctrl+enter",
"when": "editorTextFocus && inputFocus && notebookEditorFocused && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts",
"command": "notebook.cell.execute"
"command": "jupyter.notebookeditor.keybind.executeCell"
},
{
"key": "ctrl+enter",
Expand Down
1 change: 1 addition & 0 deletions src/client/common/application/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface ICommandNameWithoutArgumentTypeMapping {
[DSCommands.ResetLoggingLevel]: [];
[DSCommands.OpenVariableView]: [];
[DSCommands.NotebookEditorToggleOutput]: [];
[DSCommands.NotebookEditorKeybindExecuteCell]: [];
[DSCommands.NotebookEditorKeybindRenderMarkdownAndSelectBelow]: [];
['notebook.cell.quitEdit']: [];
['notebook.cell.executeAndSelectBelow']: [];
Expand Down
7 changes: 7 additions & 0 deletions src/client/datascience/commands/notebookCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class NotebookCommands implements IDisposable {
this.commandManager.registerCommand(Commands.NotebookEditorKeybindSave, this.keybindSave, this),
this.commandManager.registerCommand(Commands.NotebookEditorKeybindUndo, this.keybindUndo, this),
this.commandManager.registerCommand(Commands.NotebookEditorToggleOutput, this.toggleOutput, this),
this.commandManager.registerCommand(Commands.NotebookEditorKeybindExecuteCell, this.executeCell, this),
this.commandManager.registerCommand(
Commands.NotebookEditorKeybindRenderMarkdownAndSelectBelow,
this.renderMarkdownAndSelectBelow,
Expand All @@ -56,6 +57,12 @@ export class NotebookCommands implements IDisposable {
}
}

private executeCell() {
void this.commandManager
.executeCommand('notebook.cell.execute')
.then(() => this.commandManager.executeCommand('notebook.cell.quitEdit'));
}

private renderMarkdownAndSelectBelow() {
void this.commandManager
.executeCommand('notebook.cell.quitEdit')
Expand Down
1 change: 1 addition & 0 deletions src/client/datascience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export namespace Commands {
export const NotebookEditorKeybindUndo = 'jupyter.notebookeditor.keybind.undo';
export const NotebookEditorKeybindRenderMarkdownAndSelectBelow =
'jupyter.notebookeditor.keybind.renderMarkdownAndSelectBelow';
export const NotebookEditorKeybindExecuteCell = 'jupyter.notebookeditor.keybind.executeCell';
export const NotebookEditorToggleOutput = 'jupyter.notebookeditor.keybind.toggleOutput';
}

Expand Down

0 comments on commit e80d967

Please sign in to comment.