diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js
index 1e8b1551f..526862660 100644
--- a/IPython/frontend/html/notebook/static/js/codecell.js
+++ b/IPython/frontend/html/notebook/static/js/codecell.js
@@ -22,6 +22,7 @@ var IPython = (function (IPython) {
this.code_mirror = null;
this.input_prompt_number = null;
this.tooltip_on_tab = true;
+ this.collapsed = false;
IPython.Cell.apply(this, arguments);
};
@@ -200,17 +201,20 @@ var IPython = (function (IPython) {
CodeCell.prototype.collapse = function () {
- this.output_area.collapse();
+ this.collapsed = true;
+ this.output_area.collapse();
};
CodeCell.prototype.expand = function () {
- this.output_area.expand();
+ this.collapsed = false;
+ this.output_area.expand();
};
CodeCell.prototype.toggle_output = function () {
- this.output_area.toggle_output();
+ this.collapsed = Boolean(1 - this.collapsed);
+ this.output_area.toggle_output();
};