From 34481cb7eddc44214585ca97c9e9ddcfc3a437de Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 15 Dec 2015 11:08:18 +0100 Subject: [PATCH 1/3] Don't clear output on set_next_input(replace=True) rewriting input shouldn't force removal of output --- notebook/static/notebook/js/notebook.js | 1 - 1 file changed, 1 deletion(-) diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 60af9da51..bfdad831a 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -197,7 +197,6 @@ 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(); } else { var index = that.find_cell_index(data.cell); var new_cell = that.insert_cell_below('code',index); From 98e40d7e12d97bd63fd6707c97c5dc7813fd9522 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 15 Dec 2015 14:34:14 +0100 Subject: [PATCH 2/3] Note set_next_input change in changelog --- docs/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index b02bdb970..7b5cf90b3 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -43,6 +43,7 @@ UI changes: Other improvements: - Custom KernelManager methods can be Tornado coroutines, allowing async operations. +- No longer clear output 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. From f8ede57918541b467a13ee4e4c4723fe4d1a59f5 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 15 Dec 2015 14:41:36 +0100 Subject: [PATCH 3/3] add clear_output option to set_next_input payload default preserves prior behavior --- docs/source/changelog.rst | 2 +- notebook/static/notebook/js/codecell.js | 7 ++++++- notebook/static/notebook/js/notebook.js | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 7b5cf90b3..2cf0de860 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -43,7 +43,7 @@ UI changes: Other improvements: - Custom KernelManager methods can be Tornado coroutines, allowing async operations. -- No longer clear output when rewriting input with ``set_next_input(replace=True)``. +- 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. diff --git a/notebook/static/notebook/js/codecell.js b/notebook/static/notebook/js/codecell.js index 088249dc8..d1e7bf4f2 100644 --- a/notebook/static/notebook/js/codecell.js +++ b/notebook/static/notebook/js/codecell.js @@ -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); }; diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index bfdad831a..758120340 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -197,6 +197,10 @@ define(function (require) { this.events.on('set_next_input.Notebook', function (event, data) { if (data.replace) { data.cell.set_text(data.text); + 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);