Skip to content

Commit

Permalink
fix terminal::substring with brackets outside of formatting #792
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jul 10, 2022
1 parent c406c0e commit 7090d0b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
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&72e491069da397497eba7cb45413c5e5)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&a4ea61a9021e98d48ffb76a8a4247179)](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
12 changes: 12 additions & 0 deletions __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,18 @@ describe('Terminal utils', function() {
expect($.terminal.substring(input, spec[0], 200)).toEqual(spec[1]);
});
});
it('should partition the string with brackets outside of formatting', function() {
// issue #792
var text = "[this] is some [[random]] text [[;red;]hello], [[world]]";
var len = $.terminal.length(text);
var result = [];
for (var i = 0; i < len; ++i) {
result.push($.terminal.substring(text, i,i+1));
}
for (let str of result) {
expect($.terminal.length(str)).toEqual(1);
}
});
it('should return substring when input starts from normal text', function() {
var input = 'Lorem Ipsum [[;;]Dolor]';
expect($.terminal.substring(input, 10, 200)).toEqual('m [[;;]Dolor]');
Expand Down
1 change: 0 additions & 1 deletion css/jquery.terminal-src.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* Date: {{DATE}}
*/

.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
display: inline-block;
Expand Down
9 changes: 5 additions & 4 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, 28 Jun 2022 13:36:55 +0000
* Date: Sun, 10 Jul 2022 20:25:42 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5212,7 +5212,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Tue, 28 Jun 2022 13:36:55 +0000',
date: 'Sun, 10 Jul 2022 20:25:42 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -5418,8 +5418,9 @@
}
// ----------------------------------------------------------------
function is_text(i) {
return not_formatting && !opening &&
((string[i] !== ']' && !closing_formatting) || !have_formatting);
return (not_formatting && !opening &&
((string[i] !== ']' && !closing_formatting) ||
!have_formatting)) || (in_text && !formatting);
}
// ----------------------------------------------------------------
// :: function will skip to next character in main loop
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.33.3.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -5418,8 +5418,9 @@
}
// ----------------------------------------------------------------
function is_text(i) {
return not_formatting && !opening &&
((string[i] !== ']' && !closing_formatting) || !have_formatting);
return (not_formatting && !opening &&
((string[i] !== ']' && !closing_formatting) ||
!have_formatting)) || (in_text && !formatting);
}
// ----------------------------------------------------------------
// :: function will skip to next character in main loop
Expand Down
9 changes: 5 additions & 4 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, 28 Jun 2022 13:36:55 +0000
* Date: Sun, 10 Jul 2022 20:25:42 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -5212,7 +5212,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Tue, 28 Jun 2022 13:36:55 +0000',
date: 'Sun, 10 Jul 2022 20:25:42 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -5418,8 +5418,9 @@
}
// ----------------------------------------------------------------
function is_text(i) {
return not_formatting && !opening &&
((string[i] !== ']' && !closing_formatting) || !have_formatting);
return (not_formatting && !opening &&
((string[i] !== ']' && !closing_formatting) ||
!have_formatting)) || (in_text && !formatting);
}
// ----------------------------------------------------------------
// :: function will skip to next character in main loop
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 7090d0b

Please sign in to comment.