|
@@ -708,8 +708,6 @@ function addCommands(app: JupyterLab, services: ServiceManager, tracker: Noteboo
|
|
|
if (!isEnabled()) { return false; }
|
|
|
const { notebook } = tracker.currentWidget;
|
|
|
const index = notebook.activeCellIndex;
|
|
|
- // Can't run above if we are at the top of a notebook.
|
|
|
- if (index === notebook.widgets.length - 1) { return false; }
|
|
|
// If there are selections that are not the active cell,
|
|
|
// this command is confusing, so disable it.
|
|
|
for (let i = 0; i < notebook.widgets.length; ++i) {
|
|
@@ -783,7 +781,12 @@ function addCommands(app: JupyterLab, services: ServiceManager, tracker: Noteboo
|
|
|
return NotebookActions.runAllAbove(notebook, context.session);
|
|
|
}
|
|
|
},
|
|
|
- isEnabled: isEnabledAndSingleSelected
|
|
|
+ isEnabled: () => {
|
|
|
+ // Can't run above if there are multiple cells selected,
|
|
|
+ // or if we are at the top of the notebook.
|
|
|
+ return isEnabledAndSingleSelected() &&
|
|
|
+ tracker.currentWidget.notebook.activeCellIndex !== 0;
|
|
|
+ }
|
|
|
});
|
|
|
commands.addCommand(CommandIDs.runAllBelow, {
|
|
|
label: 'Run Selected Cell and All Below',
|
|
@@ -796,7 +799,13 @@ function addCommands(app: JupyterLab, services: ServiceManager, tracker: Noteboo
|
|
|
return NotebookActions.runAllBelow(notebook, context.session);
|
|
|
}
|
|
|
},
|
|
|
- isEnabled: isEnabledAndSingleSelected
|
|
|
+ isEnabled: () => {
|
|
|
+ // Can't run below if there are multiple cells selected,
|
|
|
+ // or if we are at the bottom of the notebook.
|
|
|
+ return isEnabledAndSingleSelected() &&
|
|
|
+ tracker.currentWidget.notebook.activeCellIndex !==
|
|
|
+ tracker.currentWidget.notebook.widgets.length - 1;
|
|
|
+ }
|
|
|
});
|
|
|
commands.addCommand(CommandIDs.restart, {
|
|
|
label: 'Restart Kernel…',
|