Merge pull request #340 from captainsafia/merge-cell-fix

Added fix for merge above on topmost cell to resolve #330
pull/376/merge
Matthias Bussonnier 11 years ago
commit 2c16e34a32

@ -1445,6 +1445,13 @@ define(function (require) {
if (indices.length <= 1) {
return;
}
// Check if trying to merge above on topmost cell or wrap around
// when merging above, see #330
if (indices.filter(function(item) {return item < 0}).length > 0) {
return;
}
for (var i=0; i < indices.length; i++) {
if (!this.get_cell(indices[i]).is_mergeable()) {
return;

@ -67,6 +67,21 @@ casper.notebook_test(function () {
this.test.assert(cell_is_mergeable(2), 'Cell 2 is mergeable');
});
// Try to merge cell 0 above, nothing should happen
this.then(function () {
this.select_cell(0);
});
this.thenEvaluate(function() {
IPython.notebook.merge_cell_above();
});
this.then(function() {
this.test.assertEquals(this.get_cells_length(), 3, 'Merge cell 0 above: There are still 3 cells');
this.test.assertEquals(this.get_cell_text(0), a, 'Merge cell 0 above: Cell 0 is unchanged');
this.test.assertEquals(this.get_cell_text(1), b, 'Merge cell 0 above: Cell 1 is unchanged');
this.test.assertEquals(this.get_cell_text(2), c, 'Merge cell 0 above: Cell 2 is unchanged');
this.validate_notebook_state('merge up', 'command', 0);
});
// Try to merge cell 0 below with cell 1
this.then(function () {
this.select_cell(0);

Loading…
Cancel
Save