Fix the "test for nothing was streamed" so it doesn't add empty elements -- but only when there wasn't already something there.

This commit is contained in:
Michael Droettboom 2012-04-26 10:00:16 -04:00
parent 50fa35b1cc
commit e8be6bbe50
2 changed files with 7 additions and 6 deletions

View File

@ -623,12 +623,8 @@ var IPython = (function (IPython) {
if (json.stream == undefined){
json.stream = 'stdout';
}
var text = utils.fixConsole(json.text);
if (!text){
// fixConsole gives nothing (empty string, \r, etc.)
// so don't append any elements, which might add undesirable space
return;
}
var subclass = "output_"+json.stream;
if (this.outputs.length > 0){
// have at least one output to consider
@ -644,6 +640,12 @@ var IPython = (function (IPython) {
}
}
if (!text.replace("\r", "")) {
// text is nothing (empty string, \r, etc.)
// so don't append any elements, which might add undesirable space
return;
}
// If we got here, attach a new div
var toinsert = this.create_output_area();
this.append_text(text, toinsert, "output_stream "+subclass);

View File

@ -57,7 +57,6 @@ IPython.utils = (function (IPython) {
var cmds = [];
var opener = "";
var closer = "";
// \r does nothing, so shouldn't be included
while (re.test(txt)) {
var cmds = txt.match(re)[1].split(";");
closer = opened?"</span>":"";