Permalink
Browse files

fix for #1678, undo no longer clears cells

I found another bug where switching the cell type causes the loss of all
undo history for that cell. With this commit, switching the cell type
simply resets the history
  • Loading branch information...
1 parent b9f3a3d commit 221ff6ab74ee1cf38279ad93c7f45cd1cefcfc4f @ivanov committed Jun 15, 2012
@@ -267,6 +267,9 @@ var IPython = (function (IPython) {
if (data.cell_type === 'code') {
if (data.input !== undefined) {
this.set_text(data.input);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ this.code_mirror.clearHistory();
}
if (data.prompt_number !== undefined) {
this.set_input_prompt(data.prompt_number);
@@ -602,6 +602,9 @@ var IPython = (function (IPython) {
text = '';
}
target_cell.set_text(text);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ target_cell.code_mirror.clearHistory();
source_element.remove();
this.dirty = true;
};
@@ -623,6 +626,9 @@ var IPython = (function (IPython) {
// The edit must come before the set_text.
target_cell.edit();
target_cell.set_text(text);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ target_cell.code_mirror.clearHistory();
source_element.remove();
this.dirty = true;
};
@@ -645,6 +651,9 @@ var IPython = (function (IPython) {
// The edit must come before the set_text.
target_cell.edit();
target_cell.set_text(text);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ target_cell.code_mirror.clearHistory();
source_element.remove();
this.dirty = true;
};
@@ -667,6 +676,9 @@ var IPython = (function (IPython) {
// The edit must come before the set_text.
target_cell.edit();
target_cell.set_text(text);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ target_cell.code_mirror.clearHistory();
source_element.remove();
this.dirty = true;
};
@@ -693,6 +705,9 @@ var IPython = (function (IPython) {
target_cell.set_level(level);
target_cell.edit();
target_cell.set_text(text);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ target_cell.code_mirror.clearHistory();
source_element.remove();
this.dirty = true;
};
@@ -158,6 +158,9 @@ var IPython = (function (IPython) {
if (data.cell_type === this.cell_type) {
if (data.source !== undefined) {
this.set_text(data.source);
+ // make this value the starting point, so that we can only undo
+ // to this state, instead of a blank cell
+ this.code_mirror.clearHistory();
this.set_rendered(data.rendered || '');
this.rendered = false;
this.render();

0 comments on commit 221ff6a

Please sign in to comment.