Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
"key": "escape",
"when": "isCompositeNotebook && !editorHoverVisible && !suggestWidgetVisible && !isComposing && !inSnippetMode && !exceptionWidgetVisible && !selectionAnchorSet && !LinkedEditingInputVisible && !renameInputVisible && !editorHasSelection && !accessibilityHelpWidgetVisible && !breakpointWidgetVisible && !findWidgetVisible && !markersNavigationVisible && !parameterHintsVisible && !editorHasMultipleSelections && !notificationToastsVisible && !notebookEditorFocused && !inlineChatVisible",
"command": "interactive.input.clear"
},
{
"key": "cmd+enter",
"mac": "cmd+enter",
"win": "ctrl+enter",
"linux": "ctrl+enter",
"when": "notebookEditorFocused && !findInputFocussed && !replaceInputFocussed",
"command": "jupyter.notebookeditor.runfocusedcell"
}
],
"commands": [
Expand Down Expand Up @@ -544,6 +552,12 @@
"category": "Notebook",
"enablement": "!jupyter.webExtension"
},
{
"command": "jupyter.notebookeditor.runfocusedcell",
"title": "%jupyter.command.jupyter.notebookeditor.runfocusedcell.title%",
"category": "Notebook",
"enablement": "notebookEditorFocused"
},
{
"command": "jupyter.expandallcells",
"title": "%jupyter.command.jupyter.expandallcells.title%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"message": "Add Empty Cell to Notebook File",
"comment": ["{Locked='Notebook'}"]
},
"jupyter.command.jupyter.notebookeditor.runfocusedcell.title": "Run Focused Cell",
"jupyter.command.jupyter.interruptkernel.title": "Interrupt Kernel",
"jupyter.command.jupyter.interruptkernel.shorttitle": "Interrupt",
"jupyter.command.jupyter.restartkernel.title": "Restart Kernel",
Expand Down
1 change: 1 addition & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface ICommandNameArgumentTypeMapping {
[DSCommands.RestartKernelAndRunUpToSelectedCell]: [{ notebookEditor: { notebookUri: Uri } } | undefined];
[DSCommands.NotebookEditorRemoveAllCells]: [];
[DSCommands.NotebookEditorRunAllCells]: [];
[DSCommands.NotebookEditorRunFocusedCell]: [];
[DSCommands.NotebookEditorAddCellBelow]: [];
[DSCommands.ExpandAllCells]: [];
[DSCommands.CollapseAllCells]: [];
Expand Down
24 changes: 24 additions & 0 deletions src/notebooks/notebookCommandListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export class NotebookCommandListener implements INotebookCommandHandler, IExtens
this.disposableRegistry.push(
commands.registerCommand(Commands.NotebookEditorRunAllCells, () => this.runAllCells())
);
this.disposableRegistry.push(
commands.registerCommand(Commands.NotebookEditorRunFocusedCell, () => this.runFocusedCell())
);
this.disposableRegistry.push(
commands.registerCommand(Commands.NotebookEditorAddCellBelow, () => this.addCellBelow())
);
Expand Down Expand Up @@ -115,6 +118,27 @@ export class NotebookCommandListener implements INotebookCommandHandler, IExtens
}
}

private runFocusedCell() {
const editor = window.activeNotebookEditor;
if (!editor) {
return;
}

// Get the first selection range
const range = editor.selections[0];
if (!range) {
return;
}

// Execute the cell at the start of the selection
commands
.executeCommand('notebook.cell.execute', {
ranges: [{ start: range.start, end: range.start + 1 }],
document: editor.notebook.uri
})
.then(noop, noop);
}

private addCellBelow() {
if (window.activeNotebookEditor) {
commands.executeCommand('notebook.cell.insertCodeCellBelow').then(noop, noop);
Expand Down
1 change: 1 addition & 0 deletions src/platform/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export namespace Commands {
export const NotebookEditorRemoveAllCells = 'jupyter.notebookeditor.removeallcells';
export const NotebookEditorRunAllCells = 'jupyter.notebookeditor.runallcells';
export const NotebookEditorRunSelectedCell = 'jupyter.notebookeditor.runselectedcell';
export const NotebookEditorRunFocusedCell = 'jupyter.notebookeditor.runfocusedcell';
export const NotebookEditorAddCellBelow = 'jupyter.notebookeditor.addcellbelow';
export const ExpandAllCells = 'jupyter.expandallcells';
export const CollapseAllCells = 'jupyter.collapseallcells';
Expand Down