Skip to content

Commit b3a2495

Browse files
committed
fix resolving promise from typing animation after async command #797
1 parent 4e46953 commit b3a2495

9 files changed

+46
-22
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* improve TypeScript types for typing animation [#794](https://github.com/jcubic/jquery.terminal/issues/794)
1010
* add missing mousewheel typing animation [#795](https://github.com/jcubic/jquery.terminal/issues/795)
1111
* fix iterate formatting over closing bracket [#792](https://github.com/jcubic/jquery.terminal/issues/792)
12+
* fix resolving promise from echo typing animation when previous command was async [#797](https://github.com/jcubic/jquery.terminal/issues/797)
1213

1314
## 2.33.3
1415
### Bugfix

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
99
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
1010
[![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)
11-
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&d6690de257147887b9c38f73c9cdd577)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
11+
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&874620357ad31a35421ea4b585c4546a)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
1212
![downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
1313
[![Paid Support](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery.terminal)
1414
[![](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)

__tests__/terminal.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -5075,6 +5075,14 @@ describe('Terminal plugin', function() {
50755075
await term.insert('_world', { typing: true, delay: 0});
50765076
expect(term.get_command()).toEqual('hello_world');
50775077
});
5078+
// issue #797
5079+
it('should resolve animation after async command', async () => {
5080+
term.echo(delay(0, () => "A"));
5081+
const fn = jest.fn();
5082+
term.echo("B", { typing: true, delay: 0 }).then(fn);
5083+
await delay(200);
5084+
expect(fn).toHaveBeenCalled();
5085+
});
50785086
});
50795087

50805088
describe('exec', function() {

js/jquery.terminal-2.33.3.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* broken image by Sophia Bai from the Noun Project (CC-BY)
4343
*
44-
* Date: Tue, 14 Jun 2022 20:21:33 +0000
44+
* Date: Tue, 14 Jun 2022 22:36:03 +0000
4545
*/
4646
/* global define, Map */
4747
/* eslint-disable */
@@ -5212,7 +5212,7 @@
52125212
// -------------------------------------------------------------------------
52135213
$.terminal = {
52145214
version: 'DEV',
5215-
date: 'Tue, 14 Jun 2022 20:21:33 +0000',
5215+
date: 'Tue, 14 Jun 2022 22:36:03 +0000',
52165216
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
52175217
color_names: [
52185218
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
@@ -10372,9 +10372,9 @@
1037210372
// :: advanced server side controling of terminal
1037310373
// :: you can echo: promise, function, strings array or string
1037410374
// -------------------------------------------------------------
10375-
echo: function(arg, options) {
10375+
echo: function(arg, options, deferred) {
1037610376
var arg_defined = arguments.length > 0;
10377-
var d = new $.Deferred();
10377+
var d = deferred || new $.Deferred();
1037810378
function cont() {
1037910379
echo_promise = false;
1038010380
var original = echo_delay;
@@ -10522,12 +10522,17 @@
1052210522
}
1052310523
}
1052410524
}
10525+
var animation = options && options.typing;
1052510526
if (echo_promise) {
10526-
echo_delay.push([arg, options]);
10527+
var args = [arg, options];
10528+
if (animation) {
10529+
args.push(d);
10530+
}
10531+
echo_delay.push(args);
1052710532
} else {
1052810533
echo(arg);
1052910534
}
10530-
if (options && options.typing) {
10535+
if (animation) {
1053110536
return d.promise();
1053210537
}
1053310538
return self;

js/jquery.terminal-2.33.3.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal-src.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -10372,9 +10372,9 @@
1037210372
// :: advanced server side controling of terminal
1037310373
// :: you can echo: promise, function, strings array or string
1037410374
// -------------------------------------------------------------
10375-
echo: function(arg, options) {
10375+
echo: function(arg, options, deferred) {
1037610376
var arg_defined = arguments.length > 0;
10377-
var d = new $.Deferred();
10377+
var d = deferred || new $.Deferred();
1037810378
function cont() {
1037910379
echo_promise = false;
1038010380
var original = echo_delay;
@@ -10522,12 +10522,17 @@
1052210522
}
1052310523
}
1052410524
}
10525+
var animation = options && options.typing;
1052510526
if (echo_promise) {
10526-
echo_delay.push([arg, options]);
10527+
var args = [arg, options];
10528+
if (animation) {
10529+
args.push(d);
10530+
}
10531+
echo_delay.push(args);
1052710532
} else {
1052810533
echo(arg);
1052910534
}
10530-
if (options && options.typing) {
10535+
if (animation) {
1053110536
return d.promise();
1053210537
}
1053310538
return self;

js/jquery.terminal.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* broken image by Sophia Bai from the Noun Project (CC-BY)
4343
*
44-
* Date: Tue, 14 Jun 2022 20:21:33 +0000
44+
* Date: Tue, 14 Jun 2022 22:36:03 +0000
4545
*/
4646
/* global define, Map */
4747
/* eslint-disable */
@@ -5212,7 +5212,7 @@
52125212
// -------------------------------------------------------------------------
52135213
$.terminal = {
52145214
version: 'DEV',
5215-
date: 'Tue, 14 Jun 2022 20:21:33 +0000',
5215+
date: 'Tue, 14 Jun 2022 22:36:03 +0000',
52165216
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
52175217
color_names: [
52185218
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
@@ -10372,9 +10372,9 @@
1037210372
// :: advanced server side controling of terminal
1037310373
// :: you can echo: promise, function, strings array or string
1037410374
// -------------------------------------------------------------
10375-
echo: function(arg, options) {
10375+
echo: function(arg, options, deferred) {
1037610376
var arg_defined = arguments.length > 0;
10377-
var d = new $.Deferred();
10377+
var d = deferred || new $.Deferred();
1037810378
function cont() {
1037910379
echo_promise = false;
1038010380
var original = echo_delay;
@@ -10522,12 +10522,17 @@
1052210522
}
1052310523
}
1052410524
}
10525+
var animation = options && options.typing;
1052510526
if (echo_promise) {
10526-
echo_delay.push([arg, options]);
10527+
var args = [arg, options];
10528+
if (animation) {
10529+
args.push(d);
10530+
}
10531+
echo_delay.push(args);
1052710532
} else {
1052810533
echo(arg);
1052910534
}
10530-
if (options && options.typing) {
10535+
if (animation) {
1053110536
return d.promise();
1053210537
}
1053310538
return self;

js/jquery.terminal.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)