Skip to content

Commit 4072bfb

Browse files
authored
Merge branch 'main' into jk/feat/snowflake
2 parents 122e067 + e683e42 commit 4072bfb

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
"key": "escape",
7171
"when": "isCompositeNotebook && !editorHoverVisible && !suggestWidgetVisible && !isComposing && !inSnippetMode && !exceptionWidgetVisible && !selectionAnchorSet && !LinkedEditingInputVisible && !renameInputVisible && !editorHasSelection && !accessibilityHelpWidgetVisible && !breakpointWidgetVisible && !findWidgetVisible && !markersNavigationVisible && !parameterHintsVisible && !editorHasMultipleSelections && !notificationToastsVisible && !notebookEditorFocused && !inlineChatVisible",
7272
"command": "interactive.input.clear"
73+
},
74+
{
75+
"key": "cmd+enter",
76+
"mac": "cmd+enter",
77+
"win": "ctrl+enter",
78+
"linux": "ctrl+enter",
79+
"when": "notebookEditorFocused && !findInputFocussed && !replaceInputFocussed",
80+
"command": "jupyter.notebookeditor.runfocusedcell"
7381
}
7482
],
7583
"commands": [
@@ -544,6 +552,12 @@
544552
"category": "Notebook",
545553
"enablement": "!jupyter.webExtension"
546554
},
555+
{
556+
"command": "jupyter.notebookeditor.runfocusedcell",
557+
"title": "%jupyter.command.jupyter.notebookeditor.runfocusedcell.title%",
558+
"category": "Notebook",
559+
"enablement": "notebookEditorFocused"
560+
},
547561
{
548562
"command": "jupyter.expandallcells",
549563
"title": "%jupyter.command.jupyter.expandallcells.title%",
@@ -714,9 +728,30 @@
714728
{
715729
"id": "editor.interactiveWindow.context",
716730
"label": "%jupyter.command.editor.interactiveWindow.context.label%"
731+
},
732+
{
733+
"id": "deepnote.explorer.context",
734+
"label": "Deepnote"
717735
}
718736
],
719737
"menus": {
738+
"view/title": [
739+
{
740+
"command": "deepnote.newProject",
741+
"when": "view == deepnoteExplorer",
742+
"group": "navigation@1"
743+
},
744+
{
745+
"command": "deepnote.importNotebook",
746+
"when": "view == deepnoteExplorer",
747+
"group": "navigation@2"
748+
},
749+
{
750+
"command": "deepnote.refreshExplorer",
751+
"when": "view == deepnoteExplorer",
752+
"group": "navigation@3"
753+
}
754+
],
720755
"editor/context": [
721756
{
722757
"submenu": "editor.interactiveWindow.context",
@@ -765,6 +800,14 @@
765800
"when": "editorFocus && editorLangId == python && !notebookEditorFocused && isWorkspaceTrusted"
766801
}
767802
],
803+
"deepnote.explorer.context": [
804+
{
805+
"command": "deepnote.newProject"
806+
},
807+
{
808+
"command": "deepnote.importNotebook"
809+
}
810+
],
768811
"editor/title": [
769812
{
770813
"command": "jupyter.restartkernel",
@@ -937,6 +980,11 @@
937980
}
938981
],
939982
"explorer/context": [
983+
{
984+
"submenu": "deepnote.explorer.context",
985+
"when": "isWorkspaceTrusted",
986+
"group": "navigation@10"
987+
},
940988
{
941989
"when": "resourceLangId == python && !notebookEditorFocused && isWorkspaceTrusted",
942990
"command": "jupyter.runFileInteractive",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"message": "Add Empty Cell to Notebook File",
9393
"comment": ["{Locked='Notebook'}"]
9494
},
95+
"jupyter.command.jupyter.notebookeditor.runfocusedcell.title": "Run Focused Cell",
9596
"jupyter.command.jupyter.interruptkernel.title": "Interrupt Kernel",
9697
"jupyter.command.jupyter.interruptkernel.shorttitle": "Interrupt",
9798
"jupyter.command.jupyter.restartkernel.title": "Restart Kernel",

src/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface ICommandNameArgumentTypeMapping {
5858
[DSCommands.RestartKernelAndRunUpToSelectedCell]: [{ notebookEditor: { notebookUri: Uri } } | undefined];
5959
[DSCommands.NotebookEditorRemoveAllCells]: [];
6060
[DSCommands.NotebookEditorRunAllCells]: [];
61+
[DSCommands.NotebookEditorRunFocusedCell]: [];
6162
[DSCommands.NotebookEditorAddCellBelow]: [];
6263
[DSCommands.ExpandAllCells]: [];
6364
[DSCommands.CollapseAllCells]: [];

src/notebooks/notebookCommandListener.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export class NotebookCommandListener implements INotebookCommandHandler, IExtens
6868
this.disposableRegistry.push(
6969
commands.registerCommand(Commands.NotebookEditorRunAllCells, () => this.runAllCells())
7070
);
71+
this.disposableRegistry.push(
72+
commands.registerCommand(Commands.NotebookEditorRunFocusedCell, () => this.runFocusedCell())
73+
);
7174
this.disposableRegistry.push(
7275
commands.registerCommand(Commands.NotebookEditorAddCellBelow, () => this.addCellBelow())
7376
);
@@ -115,6 +118,27 @@ export class NotebookCommandListener implements INotebookCommandHandler, IExtens
115118
}
116119
}
117120

121+
private runFocusedCell() {
122+
const editor = window.activeNotebookEditor;
123+
if (!editor) {
124+
return;
125+
}
126+
127+
// Get the first selection range
128+
const range = editor.selections[0];
129+
if (!range) {
130+
return;
131+
}
132+
133+
// Execute the cell at the start of the selection
134+
commands
135+
.executeCommand('notebook.cell.execute', {
136+
ranges: [{ start: range.start, end: range.start + 1 }],
137+
document: editor.notebook.uri
138+
})
139+
.then(noop, noop);
140+
}
141+
118142
private addCellBelow() {
119143
if (window.activeNotebookEditor) {
120144
commands.executeCommand('notebook.cell.insertCodeCellBelow').then(noop, noop);

src/platform/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export namespace Commands {
189189
export const NotebookEditorRemoveAllCells = 'jupyter.notebookeditor.removeallcells';
190190
export const NotebookEditorRunAllCells = 'jupyter.notebookeditor.runallcells';
191191
export const NotebookEditorRunSelectedCell = 'jupyter.notebookeditor.runselectedcell';
192+
export const NotebookEditorRunFocusedCell = 'jupyter.notebookeditor.runfocusedcell';
192193
export const NotebookEditorAddCellBelow = 'jupyter.notebookeditor.addcellbelow';
193194
export const ExpandAllCells = 'jupyter.expandallcells';
194195
export const CollapseAllCells = 'jupyter.collapseallcells';

0 commit comments

Comments
 (0)