Merge pull request #875 from minrk/set_next_input_clear_optional

add clear_output option to set_next_input payload
This commit is contained in:
Matthias Bussonnier 2015-12-16 10:32:45 +01:00
commit dc3dae96b6
3 changed files with 11 additions and 2 deletions

View File

@ -43,6 +43,7 @@ UI changes:
Other improvements:
- Custom KernelManager methods can be Tornado coroutines, allowing async operations.
- Make clearing output optional when rewriting input with ``set_next_input(replace=True)``.
- Added support for TLS client authentication via ``--NotebookApp.client-ca``.
- Added tags to ``jupyter/notebook`` releases on DockerHub. ``latest`` continues to track the master branch.

View File

@ -385,7 +385,12 @@ define([
* @private
*/
CodeCell.prototype._handle_set_next_input = function (payload) {
var data = {'cell': this, 'text': payload.text, replace: payload.replace};
var data = {
cell: this,
text: payload.text,
replace: payload.replace,
clear_output: payload.clear_output,
};
this.events.trigger('set_next_input.Notebook', data);
};

View File

@ -197,7 +197,10 @@ define(function (require) {
this.events.on('set_next_input.Notebook', function (event, data) {
if (data.replace) {
data.cell.set_text(data.text);
data.cell.clear_output();
if (data.clear_output !== false) {
// default (undefined) is true to preserve prior behavior
data.cell.clear_output();
}
} else {
var index = that.find_cell_index(data.cell);
var new_cell = that.insert_cell_below('code',index);