diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js
index cbb859ab9..6b46e9d83 100644
--- a/IPython/html/static/notebook/js/keyboardmanager.js
+++ b/IPython/html/static/notebook/js/keyboardmanager.js
@@ -167,6 +167,13 @@ var IPython = (function (IPython) {
};
}
},
+ 'alt+-' : {
+ help : 'split cell',
+ handler : function (event) {
+ IPython.notebook.split_cell();
+ return false;
+ }
+ },
}
// Command mode defaults
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index 38b5d0a8e..65df08c03 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -1053,27 +1053,31 @@ var IPython = (function (IPython) {
if (cell.is_splittable()) {
var texta = cell.get_pre_cursor();
var textb = cell.get_post_cursor();
+ var mode = cell.mode;
if (cell instanceof IPython.CodeCell) {
+ // In this case the operations keep the notebook in its existing mode
+ // so we don't need to do any post-op mode changes.
cell.set_text(textb);
var new_cell = this.insert_cell_above('code');
new_cell.set_text(texta);
- this.select_next();
- } else if (cell instanceof IPython.MarkdownCell) {
- var render = cell.rendered;
+ } else if (cell instanceof IPython.MarkdownCell && !cell.rendered) {
cell.set_text(textb);
cell.render();
var new_cell = this.insert_cell_above('markdown');
- new_cell.unrender(); // editor must be visible to call set_text
+ // Editor must be visible to call set_text, so we unrender.
+ // Note that this call will focus the CM editor, which selects
+ // this cell and enters edit mode.
+ new_cell.unrender();
new_cell.set_text(texta);
new_cell.render();
- this.select_next();
- if (!render) {
- // The final rendered state of the split cells should
- // match the original cell's state. The order matters
- // here as we want the lower cell (cell) to be selected.
- new_cell.unrender();
- cell.unrender();
- }
+ // The final rendered state of the split cells should
+ // match the original cell's state. The order matters
+ // here as we want the lower cell (cell) to be selected.
+ // Each of these involves a CM focus and cell select.
+ new_cell.unrender();
+ cell.unrender();
+ console.log('setting edit mode...')
+ this.edit_mode();
}
};
};
diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js
index 45ddf1933..cf0edbc74 100644
--- a/IPython/html/static/notebook/js/textcell.js
+++ b/IPython/html/static/notebook/js/textcell.js
@@ -262,21 +262,6 @@ var IPython = (function (IPython) {
};
};
-
- /** @method at_bottom **/
- TextCell.prototype.at_bottom = function () {
- if (this.rendered) {
- return true
- } else {
- var cursor = this.code_mirror.getCursor();
- if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
- return true;
- } else {
- return false;
- };
- };
- };
-
/**
* @method at_bottom
* @return {Boolean}