Skip to content

Commit

Permalink
fix resume on exception #875
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Apr 24, 2023
1 parent ed29a4d commit a40fda5
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 21 deletions.
3 changes: 1 addition & 2 deletions 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&3cf8f3d395efec4ade09abc388a5f051)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&3e72c4200d7d20c29890a518cd01cd83)](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 Expand Up @@ -282,7 +282,6 @@ If you want to start with jQuery Terminal you can look at those tutorials:

* [How to create interactive terminal like website?](https://itnext.io/how-to-create-interactive-terminal-like-website-888bb0972288)
* [How to Build Simple Terminal like Website using jQuery?](https://www.geeksforgeeks.org/how-to-build-simple-terminal-like-website-using-jquery/)
* [How to create your own custom AI Chatbot with a text editor & 28 lines of Javascript](https://medium.com/@tristwolff/how-to-create-your-own-custom-ai-chatbot-with-a-text-editor-28-lines-of-javascript-29563510a740)

### Security

Expand Down
15 changes: 15 additions & 0 deletions __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6409,6 +6409,7 @@ describe('Terminal plugin', function() {
});
describe('exception', function() {
var error = new Error('Some Message');
var get;
var term;
var lines = [
'function foo(a, b) {',
Expand All @@ -6421,6 +6422,7 @@ describe('Terminal plugin', function() {
term = $('<div/>').terminal($.noop, {
greetings: false
});
get = $.get;
if (error.stack) {
var length = Math.max.apply(Math, error.stack.split("\n").map(function(line) {
return line.length;
Expand All @@ -6430,6 +6432,7 @@ describe('Terminal plugin', function() {
});
afterEach(function() {
term.destroy().remove();
$.get = get;
});
it('should show exception', function() {
term.exception(error, 'ERROR');
Expand Down Expand Up @@ -6500,6 +6503,18 @@ describe('Terminal plugin', function() {
done();
}, 10);
});
it('should not resume the terminal', () => {
var error = {
message: 'Some Message',
fileName: 'http://localhost/file.js',
lineNumber: 2
};
term.clear().exception(error, 'foo');
term.clear().pause();
expect(term.paused()).toBe(true);
term.exception(error, 'user');
expect(term.paused()).toBe(true);
});
});
describe('scroll', function() {
var term = $('<div/>').terminal($.noop, {
Expand Down
17 changes: 11 additions & 6 deletions js/jquery.terminal-2.35.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: Mon, 10 Apr 2023 15:22:41 +0000
* Date: Mon, 24 Apr 2023 11:34:59 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5274,7 +5274,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 10 Apr 2023 15:22:41 +0000',
date: 'Mon, 24 Apr 2023 11:34: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 @@ -7400,9 +7400,7 @@
linksNoFollow: false,
processRPCResponse: null,
completionEscape: true,
onCommandChange: null,
mobileDelete: is_mobile,
onPositionChange: null,
convertLinks: true,
extra: {},
tabs: 4,
Expand Down Expand Up @@ -7462,6 +7460,8 @@
onBeforeLogin: null,
onAfterLogout: null,
onBeforeLogout: null,
onCommandChange: null,
onPositionChange: null,
allowedAttributes: ['title', 'target', 'rel', /^aria-/, 'id', /^data-/],
strings: {
comletionParameters: 'From version 1.0.0 completion function need to' +
Expand Down Expand Up @@ -10903,14 +10903,19 @@
}
if (typeof e.fileName === 'string') {
// display filename and line which throw exeption
self.pause(settings.softPause);
var was_pased = self.paused();
if (!was_pased) {
self.pause(settings.softPause);
}
$.get(e.fileName, function(file) {
var num = e.lineNumber - 1;
var line = file.split('\n')[num];
if (line) {
self.error('[' + e.lineNumber + ']: ' + line);
}
self.resume();
if (!was_pased) {
self.resume();
}
}, 'text');
}
if (e.stack) {
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.35.3.min.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -10903,14 +10903,19 @@
}
if (typeof e.fileName === 'string') {
// display filename and line which throw exeption
self.pause(settings.softPause);
var was_pased = self.paused();
if (!was_pased) {
self.pause(settings.softPause);
}
$.get(e.fileName, function(file) {
var num = e.lineNumber - 1;
var line = file.split('\n')[num];
if (line) {
self.error('[' + e.lineNumber + ']: ' + line);
}
self.resume();
if (!was_pased) {
self.resume();
}
}, 'text');
}
if (e.stack) {
Expand Down
2 changes: 2 additions & 0 deletions js/jquery.terminal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ declare namespace JQueryTerminal {
type ExtendedPrompt = ((this: JQueryTerminal, setPrompt: setStringFunction) => (void | PromiseLike<string>)) | string;

type MouseWheelCallback = (event: MouseEvent, delta: number, self: JQueryTerminal) => boolean | void;
type TouchScrollCallback = MouseWheelCallback;

type execOptions = JQueryTerminal.animationOptions & {
silent?: boolean;
Expand All @@ -178,6 +179,7 @@ declare namespace JQueryTerminal {
keypress?: KeyEventHandler;
keydown?: KeyEventHandler;
mousewheel?: MouseWheelCallback;
touchscroll: TouchScrollCallback;
keymap?: keymapObject;
history?: boolean;
name?: string;
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: Mon, 10 Apr 2023 15:22:41 +0000
* Date: Mon, 24 Apr 2023 11:34:59 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5274,7 +5274,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 10 Apr 2023 15:22:41 +0000',
date: 'Mon, 24 Apr 2023 11:34: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 @@ -7400,9 +7400,7 @@
linksNoFollow: false,
processRPCResponse: null,
completionEscape: true,
onCommandChange: null,
mobileDelete: is_mobile,
onPositionChange: null,
convertLinks: true,
extra: {},
tabs: 4,
Expand Down Expand Up @@ -7462,6 +7460,8 @@
onBeforeLogin: null,
onAfterLogout: null,
onBeforeLogout: null,
onCommandChange: null,
onPositionChange: null,
allowedAttributes: ['title', 'target', 'rel', /^aria-/, 'id', /^data-/],
strings: {
comletionParameters: 'From version 1.0.0 completion function need to' +
Expand Down Expand Up @@ -10903,14 +10903,19 @@
}
if (typeof e.fileName === 'string') {
// display filename and line which throw exeption
self.pause(settings.softPause);
var was_pased = self.paused();
if (!was_pased) {
self.pause(settings.softPause);
}
$.get(e.fileName, function(file) {
var num = e.lineNumber - 1;
var line = file.split('\n')[num];
if (line) {
self.error('[' + e.lineNumber + ']: ' + line);
}
self.resume();
if (!was_pased) {
self.resume();
}
}, 'text');
}
if (e.stack) {
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 a40fda5

Please sign in to comment.