|
@@ -489,7 +489,7 @@ class CodeCell extends Cell {
|
|
|
// Set a CSS if there are no outputs, and connect a signal for future
|
|
|
// changes to the number of outputs. This is for conditional styling
|
|
|
// if there are no outputs.
|
|
|
- if (model.outputs.length===0) {
|
|
|
+ if (model.outputs.length === 0) {
|
|
|
this.addClass(NO_OUTPUTS_CLASS);
|
|
|
}
|
|
|
output.outputLengthChanged.connect(this._outputLengthHandler, this);
|
|
@@ -540,33 +540,6 @@ class CodeCell extends Cell {
|
|
|
super.dispose();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Execute the cell given a client session.
|
|
|
- */
|
|
|
- execute(session: IClientSession): Promise<KernelMessage.IExecuteReplyMsg> {
|
|
|
- let model = this.model;
|
|
|
- let code = model.value.text;
|
|
|
- if (!code.trim() || !session.kernel) {
|
|
|
- model.executionCount = null;
|
|
|
- model.outputs.clear();
|
|
|
- return Promise.resolve(null);
|
|
|
- }
|
|
|
- model.executionCount = null;
|
|
|
- this.setPrompt('*');
|
|
|
- this.model.trusted = true;
|
|
|
-
|
|
|
- return this._output.execute(code, session).then(reply => {
|
|
|
- let status = reply.content.status;
|
|
|
- if (status === 'abort') {
|
|
|
- model.executionCount = null;
|
|
|
- this.setPrompt(' ');
|
|
|
- } else {
|
|
|
- model.executionCount = reply.content.execution_count;
|
|
|
- }
|
|
|
- return reply;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Handle `update-request` messages.
|
|
|
*/
|
|
@@ -643,6 +616,37 @@ namespace CodeCell {
|
|
|
rendermime: RenderMime;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Execute a cell given a client session.
|
|
|
+ */
|
|
|
+ export
|
|
|
+ function execute(cell: CodeCell, session: IClientSession): Promise<KernelMessage.IExecuteReplyMsg> {
|
|
|
+ let model = cell.model;
|
|
|
+ let code = model.value.text;
|
|
|
+ if (!code.trim() || !session.kernel) {
|
|
|
+ model.executionCount = null;
|
|
|
+ model.outputs.clear();
|
|
|
+ return Promise.resolve(void 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ model.executionCount = null;
|
|
|
+ cell.setPrompt('*');
|
|
|
+
|
|
|
+ // Override the default for `stop_on_error`.
|
|
|
+ let content: KernelMessage.IExecuteRequest = {
|
|
|
+ code,
|
|
|
+ stop_on_error: true
|
|
|
+ };
|
|
|
+
|
|
|
+ let future = session.kernel.requestExecute(content);
|
|
|
+ model.trusted = true;
|
|
|
+ cell.outputArea.future = future;
|
|
|
+
|
|
|
+ return future.done.then((msg: KernelMessage.IExecuteReplyMsg) => {
|
|
|
+ model.executionCount = msg.content.execution_count;
|
|
|
+ return msg;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|