Skip to content

Commit

Permalink
fix multiple echo with !newline + !flush #709
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 13, 2021
1 parent 2f9af27 commit 1a15536
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@
* allow to escape angle brackets in XML formatting [#710](https://github.com/jcubic/jquery.terminal/issues/710)
* fix black line before the image [#708](https://github.com/jcubic/jquery.terminal/issues/708)
* fix scroll to bottom when echo an image [#716](https://github.com/jcubic/jquery.terminal/issues/716)
* fix multiple echo with `!flush && !newline` [#709](https://github.com/jcubic/jquery.terminal/issues/709)

## 2.29.5
### Bugfix
Expand Down
20 changes: 17 additions & 3 deletions js/jquery.terminal-2.29.5.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Mon, 13 Dec 2021 11:28:24 +0000
* Date: Mon, 13 Dec 2021 21:31:59 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -1872,6 +1872,14 @@
}
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.output = function() {
return this._output_buffer.slice();
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.is_empty = function() {
return !this._output_buffer.length;
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.clear = function() {
this._output_buffer = [];
};
Expand Down Expand Up @@ -5102,7 +5110,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 13 Dec 2021 11:28:24 +0000',
date: 'Mon, 13 Dec 2021 21:31:59 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -9873,6 +9881,9 @@
}, options || {});
when_ready(function ready() {
try {
if (buffer.is_empty()) {
return self;
}
var bottom = self.is_bottom();
var scroll = (settings.scrollOnEcho && options.scroll) || bottom;
var wrapper;
Expand All @@ -9888,7 +9899,7 @@
// TODO: refactor buffer.flush(), there is way
// to many levels of abstractions in one place
buffer.flush(function(data) {
if (!data) { // newline
if (!data) {
if (!partial.length) {
wrapper = $('<div/>');
snapshot = [];
Expand Down Expand Up @@ -9919,6 +9930,9 @@
wrapper.attr('data-index', data.index);
appending_to_partial = !data.newline;
wrapper.toggleClass('partial', appending_to_partial);
if (appending_to_partial) {
partial = wrapper;
}
data.finalize(wrapper);
} else {
var line = data.line;
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.29.5.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion js/jquery.terminal-src.js
Expand Up @@ -9899,7 +9899,7 @@
// TODO: refactor buffer.flush(), there is way
// to many levels of abstractions in one place
buffer.flush(function(data) {
if (!data) { // newline
if (!data) {
if (!partial.length) {
wrapper = $('<div/>');
snapshot = [];
Expand Down Expand Up @@ -9930,6 +9930,9 @@
wrapper.attr('data-index', data.index);
appending_to_partial = !data.newline;
wrapper.toggleClass('partial', appending_to_partial);
if (appending_to_partial) {
partial = wrapper;
}
data.finalize(wrapper);
} else {
var line = data.line;
Expand Down
20 changes: 17 additions & 3 deletions js/jquery.terminal.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Mon, 13 Dec 2021 11:28:24 +0000
* Date: Mon, 13 Dec 2021 21:31:59 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -1872,6 +1872,14 @@
}
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.output = function() {
return this._output_buffer.slice();
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.is_empty = function() {
return !this._output_buffer.length;
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.clear = function() {
this._output_buffer = [];
};
Expand Down Expand Up @@ -5102,7 +5110,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 13 Dec 2021 11:28:24 +0000',
date: 'Mon, 13 Dec 2021 21:31:59 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -9873,6 +9881,9 @@
}, options || {});
when_ready(function ready() {
try {
if (buffer.is_empty()) {
return self;
}
var bottom = self.is_bottom();
var scroll = (settings.scrollOnEcho && options.scroll) || bottom;
var wrapper;
Expand All @@ -9888,7 +9899,7 @@
// TODO: refactor buffer.flush(), there is way
// to many levels of abstractions in one place
buffer.flush(function(data) {
if (!data) { // newline
if (!data) {
if (!partial.length) {
wrapper = $('<div/>');
snapshot = [];
Expand Down Expand Up @@ -9919,6 +9930,9 @@
wrapper.attr('data-index', data.index);
appending_to_partial = !data.newline;
wrapper.toggleClass('partial', appending_to_partial);
if (appending_to_partial) {
partial = wrapper;
}
data.finalize(wrapper);
} else {
var line = data.line;
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit 1a15536

Please sign in to comment.