diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js
index d5b05d6..6ff3bec 100644
--- a/IPython/html/static/notebook/js/codecell.js
+++ b/IPython/html/static/notebook/js/codecell.js
@@ -105,6 +105,7 @@ var IPython = (function (IPython) {
}
};
+ CodeCell.msg_cells = {};
CodeCell.prototype = new IPython.Cell();
@@ -317,7 +318,12 @@ var IPython = (function (IPython) {
}
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});
+ if (old_msg_id) {
+ delete CodeCell.msg_cells[old_msg_id];
+ }
+ CodeCell.msg_cells[this.last_msg_id] = this;
};
/**
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index 11c9a1d..9abf8db 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -308,12 +308,8 @@ var IPython = (function (IPython) {
* @return {Cell} Cell or null if no cell was found.
*/
Notebook.prototype.get_msg_cell = function (msg_id) {
- var cells = this.get_cells();
- for (var cell_index in cells) {
- if (cells[cell_index].last_msg_id == msg_id) {
- var cell = this.get_cell(cell_index)
- return cell;
- }
+ if (IPython.CodeCell.msg_cells[msg_id] !== undefined) {
+ return IPython.CodeCell.msg_cells[msg_id];
}
return null;
};