Skip to content

Commit

Permalink
fix edge case of disappearing content after refresh
Browse files Browse the repository at this point in the history
Fix problem with `echo(..., {newline: false, flush: false})` where two lines ended
in the same container and the index came from the last line. When refreshing
the first line was ignored becuase the index in DOM was missing.
The fix was to reset the state after newline so both lines are in different
containers
  • Loading branch information
jcubic committed Jul 4, 2023
1 parent 2039f07 commit f28fec0
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@
### Bugfix
* fix CMD wrapping when prompt is empty [#882](https://github.com/jcubic/jquery.terminal/issues/882)
* fix paused terminal when using array as interpreter and RPC without system describe
* fix edge case of disappearing content after refresh [#871](https://github.com/jcubic/jquery.terminal/issues/871)

## 2.36.0
### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&5a0bd675979dfdec08c202933e7bbf66)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&e91d8ab98ab7a99d82093f92146b5e92)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![Paid Support](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
Expand Down
13 changes: 12 additions & 1 deletion __tests__/terminal.spec.js
Expand Up @@ -5860,9 +5860,20 @@ describe('Terminal plugin', function() {
term.flush();
expect(term.find('.terminal-output').text()).toEqual('foobarbaz');
});
// https://github.com/jcubic/jquery.terminal/issues/871
it('should should update lines that use newline&flush set to false', async () => {
var term = $('<div/>').terminal($.noop, { greetings: false });
term.echo('Hello', { flush: false, newline: false });
term.echo(' ', { flush: false, newline: false });
term.echo('World', { flush: false });
term.echo('Flush', { flush: false });
term.flush();
term.refresh();
expect(output(term)).toEqual(['Hello World', 'Flush']);
});
it('should flush correctly with newline : false', function(){
var term = $('<div/>').terminal($.noop, {
greetings : 'greet'
greetings: 'greet'
});
var cmd = term.find('.cmd');

Expand Down
7 changes: 5 additions & 2 deletions js/jquery.terminal-2.36.0.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Wed, 28 Jun 2023 14:16:42 +0000
* Date: Tue, 04 Jul 2023 19:13:23 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5277,7 +5277,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Wed, 28 Jun 2023 14:16:42 +0000',
date: 'Tue, 04 Jul 2023 19:13:23 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -10474,6 +10474,9 @@
wrapper.toggleClass('partial', appending_to_partial);
if (appending_to_partial) {
partial = wrapper;
} else if (data.newline && partial.length) {
//wrapper = $('<div/>');
//partial = $();
}
data.finalize(wrapper);
} else {
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.36.0.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions js/jquery.terminal-src.js
Expand Up @@ -10474,6 +10474,9 @@
wrapper.toggleClass('partial', appending_to_partial);
if (appending_to_partial) {
partial = wrapper;
} else if (data.newline && partial.length) {
wrapper = $('<div/>');
partial = $();
}
data.finalize(wrapper);
} else {
Expand Down
7 changes: 5 additions & 2 deletions js/jquery.terminal.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Wed, 28 Jun 2023 14:16:42 +0000
* Date: Tue, 04 Jul 2023 19:13:23 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5277,7 +5277,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Wed, 28 Jun 2023 14:16:42 +0000',
date: 'Tue, 04 Jul 2023 19:13:23 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -10474,6 +10474,9 @@
wrapper.toggleClass('partial', appending_to_partial);
if (appending_to_partial) {
partial = wrapper;
} else if (data.newline && partial.length) {
//wrapper = $('<div/>');
//partial = $();
}
data.finalize(wrapper);
} else {
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 f28fec0

Please sign in to comment.