Skip to content

Commit

Permalink
fix resolving promise from typing animation after async command #797
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jun 14, 2022
1 parent 4e46953 commit b3a2495
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* improve TypeScript types for typing animation [#794](https://github.com/jcubic/jquery.terminal/issues/794)
* add missing mousewheel typing animation [#795](https://github.com/jcubic/jquery.terminal/issues/795)
* fix iterate formatting over closing bracket [#792](https://github.com/jcubic/jquery.terminal/issues/792)
* fix resolving promise from echo typing animation when previous command was async [#797](https://github.com/jcubic/jquery.terminal/issues/797)

## 2.33.3
### Bugfix
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
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&d6690de257147887b9c38f73c9cdd577)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&874620357ad31a35421ea4b585c4546a)](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
8 changes: 8 additions & 0 deletions __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5075,6 +5075,14 @@ describe('Terminal plugin', function() {
await term.insert('_world', { typing: true, delay: 0});
expect(term.get_command()).toEqual('hello_world');
});
// issue #797
it('should resolve animation after async command', async () => {
term.echo(delay(0, () => "A"));
const fn = jest.fn();
term.echo("B", { typing: true, delay: 0 }).then(fn);
await delay(200);
expect(fn).toHaveBeenCalled();
});
});

describe('exec', function() {
Expand Down
17 changes: 11 additions & 6 deletions js/jquery.terminal-2.33.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Tue, 14 Jun 2022 20:21:33 +0000
* Date: Tue, 14 Jun 2022 22:36:03 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5212,7 +5212,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Tue, 14 Jun 2022 20:21:33 +0000',
date: 'Tue, 14 Jun 2022 22:36:03 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -10372,9 +10372,9 @@
// :: advanced server side controling of terminal
// :: you can echo: promise, function, strings array or string
// -------------------------------------------------------------
echo: function(arg, options) {
echo: function(arg, options, deferred) {
var arg_defined = arguments.length > 0;
var d = new $.Deferred();
var d = deferred || new $.Deferred();
function cont() {
echo_promise = false;
var original = echo_delay;
Expand Down Expand Up @@ -10522,12 +10522,17 @@
}
}
}
var animation = options && options.typing;
if (echo_promise) {
echo_delay.push([arg, options]);
var args = [arg, options];
if (animation) {
args.push(d);
}
echo_delay.push(args);
} else {
echo(arg);
}
if (options && options.typing) {
if (animation) {
return d.promise();
}
return self;
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.33.3.min.js

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -10372,9 +10372,9 @@
// :: advanced server side controling of terminal
// :: you can echo: promise, function, strings array or string
// -------------------------------------------------------------
echo: function(arg, options) {
echo: function(arg, options, deferred) {
var arg_defined = arguments.length > 0;
var d = new $.Deferred();
var d = deferred || new $.Deferred();
function cont() {
echo_promise = false;
var original = echo_delay;
Expand Down Expand Up @@ -10522,12 +10522,17 @@
}
}
}
var animation = options && options.typing;
if (echo_promise) {
echo_delay.push([arg, options]);
var args = [arg, options];
if (animation) {
args.push(d);
}
echo_delay.push(args);
} else {
echo(arg);
}
if (options && options.typing) {
if (animation) {
return d.promise();
}
return self;
Expand Down
17 changes: 11 additions & 6 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Tue, 14 Jun 2022 20:21:33 +0000
* Date: Tue, 14 Jun 2022 22:36:03 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5212,7 +5212,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Tue, 14 Jun 2022 20:21:33 +0000',
date: 'Tue, 14 Jun 2022 22:36:03 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -10372,9 +10372,9 @@
// :: advanced server side controling of terminal
// :: you can echo: promise, function, strings array or string
// -------------------------------------------------------------
echo: function(arg, options) {
echo: function(arg, options, deferred) {
var arg_defined = arguments.length > 0;
var d = new $.Deferred();
var d = deferred || new $.Deferred();
function cont() {
echo_promise = false;
var original = echo_delay;
Expand Down Expand Up @@ -10522,12 +10522,17 @@
}
}
}
var animation = options && options.typing;
if (echo_promise) {
echo_delay.push([arg, options]);
var args = [arg, options];
if (animation) {
args.push(d);
}
echo_delay.push(args);
} else {
echo(arg);
}
if (options && options.typing) {
if (animation) {
return d.promise();
}
return self;
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 b3a2495

Please sign in to comment.