|
@@ -466,6 +466,64 @@ namespace NotebookActions {
|
|
|
return promise;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Run all of the cells before the currently active cell (exclusive).
|
|
|
+ *
|
|
|
+ * @param widget - The target notebook widget.
|
|
|
+ *
|
|
|
+ * @param session - The optional client session object.
|
|
|
+ *
|
|
|
+ * #### Notes
|
|
|
+ * The existing selection will be cleared.
|
|
|
+ * An execution error will prevent the remaining code cells from executing.
|
|
|
+ * All markdown cells will be rendered.
|
|
|
+ * The currently active cell will remain selected.
|
|
|
+ */
|
|
|
+ export
|
|
|
+ function runAllAbove(widget: Notebook, session?: IClientSession): Promise<boolean> {
|
|
|
+ if (!widget.model || !widget.activeCell || widget.activeCellIndex === 0) {
|
|
|
+ return Promise.resolve(false);
|
|
|
+ }
|
|
|
+ let state = Private.getState(widget);
|
|
|
+ widget.activeCellIndex--;
|
|
|
+ widget.deselectAll();
|
|
|
+ for (let i = 0; i < widget.activeCellIndex; ++i) {
|
|
|
+ widget.select(widget.widgets[i]);
|
|
|
+ }
|
|
|
+ let promise = Private.runSelected(widget, session);
|
|
|
+ widget.activeCellIndex++;
|
|
|
+ Private.handleRunState(widget, state, true);
|
|
|
+ return promise;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Run all of the cells after the currently active cell (inclusive).
|
|
|
+ *
|
|
|
+ * @param widget - The target notebook widget.
|
|
|
+ *
|
|
|
+ * @param session - The optional client session object.
|
|
|
+ *
|
|
|
+ * #### Notes
|
|
|
+ * The existing selection will be cleared.
|
|
|
+ * An execution error will prevent the remaining code cells from executing.
|
|
|
+ * All markdown cells will be rendered.
|
|
|
+ * The last cell in the notebook will be activated and scrolled into view.
|
|
|
+ */
|
|
|
+ export
|
|
|
+ function runAllBelow(widget: Notebook, session?: IClientSession): Promise<boolean> {
|
|
|
+ if (!widget.model || !widget.activeCell) {
|
|
|
+ return Promise.resolve(false);
|
|
|
+ }
|
|
|
+ let state = Private.getState(widget);
|
|
|
+ widget.deselectAll();
|
|
|
+ for (let i = widget.activeCellIndex; i < widget.widgets.length; ++i) {
|
|
|
+ widget.select(widget.widgets[i]);
|
|
|
+ }
|
|
|
+ let promise = Private.runSelected(widget, session);
|
|
|
+ Private.handleRunState(widget, state, true);
|
|
|
+ return promise;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Select the above the active cell.
|
|
|
*
|