From 3f84cf5a94514fbf5371b67c57f0610805331c6b Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Mon, 14 Jun 2021 08:39:35 -0700 Subject: [PATCH] Port keybinding updates to release (#6268) * Contribute shift+enter, ctrl+enter, L, shift+L (#6205) * Ctrl+Enter should put cell into command mode after executing (#6231) * Update CHANGELOG and remove news --- CHANGELOG.md | 8 ++ package.json | 77 +++++++++---------- package.nls.json | 1 + src/client/common/application/commands.ts | 4 + .../datascience/commands/notebookCommands.ts | 20 ++++- src/client/datascience/constants.ts | 3 + 6 files changed, 72 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d46ea628b91..48f292eb9d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ 1. On remote connections check for new or removed LiveKernelConnections on document open. ([#5984](https://github.com/Microsoft/vscode-jupyter/issues/5984)) +1. When editing a markdown cell in preview native notebooks UI, contribute `ctrl+enter` keybinding to render current markdown cell, and `shift+enter` to render current markdown cell and skip to the next cell. + ([#5976](https://github.com/Microsoft/vscode-jupyter/issues/5976)) +1. In preview native notebooks UI, contribute `L` keybinding to toggle line numbers for the current cell, and `shift+L` keybinding to toggle line numbers for all cells. + ([#4438](https://github.com/Microsoft/vscode-jupyter/issues/4438)) +1. Contribute extension-level `shift+enter` keybinding to execute current code cell and select below in preview native notebooks UI. + ([#6037](https://github.com/Microsoft/vscode-jupyter/issues/6037)) +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. + ([#6198](https://github.com/Microsoft/vscode-jupyter/issues/6198)) ## 2021.6.99 (8 June 2021) diff --git a/package.json b/package.json index 825d3f65b21..ff51f00744c 100644 --- a/package.json +++ b/package.json @@ -98,112 +98,99 @@ "when": "editorTextFocus && !editorHasSelection && jupyter.hascodecells && !notebookEditorFocused" }, { - "mac": "F", - "win": "F", - "linux": "F", "key": "F", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.find" }, { - "mac": "K", - "win": "K", - "linux": "K", "key": "K", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "list.focusUp" }, { - "mac": "J", - "win": "J", - "linux": "J", "key": "J", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "list.focusDown" }, { - "mac": "A", - "win": "A", - "linux": "A", "key": "A", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.insertCodeCellAbove" }, { - "mac": "B", - "win": "B", - "linux": "B", "key": "B", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.insertCodeCellBelow" }, { - "mac": "D D", - "win": "D D", - "linux": "D D", "key": "D D", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.delete" }, { - "mac": "Z", - "win": "Z", - "linux": "Z", "key": "Z", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "jupyter.notebookeditor.keybind.undo" }, { - "mac": "S", - "win": "S", - "linux": "S", "key": "S", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "jupyter.notebookeditor.keybind.save" }, { - "mac": "C", - "win": "C", - "linux": "C", "key": "C", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.copy" }, { - "mac": "X", - "win": "X", - "linux": "X", "key": "X", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.cut" }, { - "mac": "V", - "win": "V", - "linux": "V", "key": "V", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.paste" }, { - "mac": "O", - "win": "O", - "linux": "O", "key": "O", "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "jupyter.notebookeditor.keybind.toggleOutput" }, { - "mac": "ctrl+shift+-", - "win": "ctrl+shift+-", - "linux": "ctrl+shift+-", + "key": "shift+L", + "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", + "command": "notebook.toggleLineNumbers" + }, + { + "key": "L", + "when": "notebookEditorFocused && !inputFocus && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", + "command": "notebook.cell.toggleLineNumbers" + }, + { + "key": "ctrl+shift+-", "when": "editorTextFocus && inputFocus && notebookEditorFocused && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts", "command": "notebook.cell.split" }, { "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", + "when": "inputFocus && notebookEditorFocused && !editorHasMultipleSelections && !editorHasSelection && !editorHoverVisible && notebookCellType == 'markup'", + "command": "notebook.cell.quitEdit" + }, + { + "key": "shift+enter", + "when": "editorTextFocus && inputFocus && notebookEditorFocused && notebookType == jupyter-notebook && config.jupyter.enableKeyboardShortcuts || notebookCellListFocused && notebookCellType == 'markup' || notebookCellListFocused && notebookCellType == 'code' && notebookCellExecutionState == 'failed' || notebookCellExecutionState == 'idle' || notebookCellExecutionState == 'succeeded' && notebookKernelCount > 0", + "command": "notebook.cell.executeAndSelectBelow" + }, + { + "key": "shift+enter", + "when": "inputFocus && notebookEditorFocused && !editorHasMultipleSelections && !editorHasSelection && !editorHoverVisible && notebookCellType == 'markup'", + "command": "jupyter.notebookeditor.keybind.renderMarkdownAndSelectBelow" }, { "command": "jupyter.insertCellBelowPosition", @@ -385,6 +372,11 @@ "title": "%DataScience.toggleCellOutput%", "category": "Notebook" }, + { + "command": "jupyter.notebookeditor.keybind.renderMarkdownAndSelectBelow", + "title": "%DataScience.renderMarkdownAndSelectBelow%", + "category": "Notebook" + }, { "command": "jupyter.selectCell", "title": "%jupyter.command.jupyter.selectCell.title%", @@ -894,6 +886,11 @@ "title": "%DataScience.toggleCellOutput%", "when": "notebookType == jupyter-notebook" }, + { + "command": "jupyter.notebookeditor.keybind.renderMarkdownAndSelectBelow", + "title": "%DataScience.renderMarkdownAndSelectBelow%", + "when": "false" + }, { "command": "jupyter.exportAsPythonScript", "title": "%jupyter.command.jupyter.exportAsPythonScript.title%", diff --git a/package.nls.json b/package.nls.json index fe83896c4da..a22d1027639 100644 --- a/package.nls.json +++ b/package.nls.json @@ -385,6 +385,7 @@ "DataScience.addCell": "Add cell", "DataScience.runAll": "Run all cells", "DataScience.toggleCellOutput": "Toggle Cell Output", + "DataScience.renderMarkdownAndSelectBelow": "Execute Notebook Cell and Select Below", "DataScience.convertingToPythonFile": "Converting ipynb to python file", "DataScience.untitledNotebookMessage": "Your changes will be lost if you don't save them.", "DataScience.untitledNotebookYes": "Save", diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index 0c48f9bf386..f6b30e1051c 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -53,6 +53,10 @@ interface ICommandNameWithoutArgumentTypeMapping { [DSCommands.ResetLoggingLevel]: []; [DSCommands.OpenVariableView]: []; [DSCommands.NotebookEditorToggleOutput]: []; + [DSCommands.NotebookEditorKeybindExecuteCell]: []; + [DSCommands.NotebookEditorKeybindRenderMarkdownAndSelectBelow]: []; + ['notebook.cell.quitEdit']: []; + ['notebook.cell.executeAndSelectBelow']: []; ['notebook.cell.collapseCellOutput']: []; ['notebook.cell.expandCellOutput']: []; } diff --git a/src/client/datascience/commands/notebookCommands.ts b/src/client/datascience/commands/notebookCommands.ts index 634c881ad05..01de8a5ea0a 100644 --- a/src/client/datascience/commands/notebookCommands.ts +++ b/src/client/datascience/commands/notebookCommands.ts @@ -38,7 +38,13 @@ export class NotebookCommands implements IDisposable { this.commandManager.registerCommand(Commands.NotebookEditorExpandAllCells, this.expandAll, this), 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.NotebookEditorToggleOutput, this.toggleOutput, this), + this.commandManager.registerCommand(Commands.NotebookEditorKeybindExecuteCell, this.executeCell, this), + this.commandManager.registerCommand( + Commands.NotebookEditorKeybindRenderMarkdownAndSelectBelow, + this.renderMarkdownAndSelectBelow, + this + ) ); } public dispose() { @@ -51,6 +57,18 @@ 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') + .then(() => this.commandManager.executeCommand('notebook.cell.executeAndSelectBelow')); + } + private collapseAll() { if (this.notebookEditorProvider.activeEditor) { this.notebookEditorProvider.activeEditor.collapseAllCells(); diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 9371c0ffb18..92d293ed852 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -162,6 +162,9 @@ export namespace Commands { export const OpenVariableView = 'jupyter.openVariableView'; export const NotebookEditorKeybindSave = 'jupyter.notebookeditor.keybind.save'; 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'; }