From a7e72f8b8000f17bf66a40615c513be106c33272 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 26 Jan 2015 10:25:17 -0800 Subject: [PATCH] don't execute empty cells reorder execute a little, so that clearing old state all happens before setting new state --- IPython/html/static/notebook/js/codecell.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index bd2fede5f..fbf3cb049 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -405,20 +405,26 @@ define([ this.widget_subarea.height(''); this.widget_area.height(''); this.widget_area.hide(); + + var old_msg_id = this.last_msg_id; + if (old_msg_id) { + this.kernel.clear_callbacks_for_msg(old_msg_id); + if (old_msg_id) { + delete CodeCell.msg_cells[old_msg_id]; + } + } + if (this.get_text().trim().length === 0) { + // nothing to do + this.set_input_prompt(null); + return; + } this.set_input_prompt('*'); this.element.addClass("running"); - if (this.last_msg_id) { - this.kernel.clear_callbacks_for_msg(this.last_msg_id); - } var callbacks = this.get_callbacks(); - var old_msg_id = this.last_msg_id; this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true, stop_on_error : stop_on_error}); - if (old_msg_id) { - delete CodeCell.msg_cells[old_msg_id]; - } CodeCell.msg_cells[this.last_msg_id] = this; this.render(); this.events.trigger('execute.CodeCell', {cell: this});