Skip to content

Commit

Permalink
fix cursor on formattings when one change the length #580
Browse files Browse the repository at this point in the history
Problem was if one formatter change length of the text and even if the cursor position
was outsite of the length changing formatter it looked like safe formatter
changed length because you could not click inside replaced text
  • Loading branch information
jcubic committed May 31, 2020
1 parent 14fd1eb commit 99ba79b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.17.0
### Features
* new CTRL+Arrow down/up shortcuts and ignore the multi line commands (change history)
* new CTRL+ARROW DOWN/UP shortcuts and ignore the multi line commands (change history)
### Bugfix
* fix ch unit bug for Firefox and IE [#579](https://github.com/jcubic/jquery.terminal/issues/579)
* fix broken emoji [#578](https://github.com/jcubic/jquery.terminal/issues/578)
Expand All @@ -12,6 +12,7 @@
* allow to use .emoji CSS in .raw output
* fix up/down on multi line command navigation when command have brackets and/or wrappings
* fix empty lines after wrapping in CMD when splitted line length == cols
* fix navigating of formatting when stacked formatters are used and one change length [#580](https://github.com/jcubic/jquery.terminal/issues/580)

## 2.16.1
### Bugfix
Expand Down
22 changes: 18 additions & 4 deletions js/jquery.terminal-2.16.1.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: Sat, 30 May 2020 16:13:11 +0000
* Date: Sun, 31 May 2020 10:59:30 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -4404,7 +4404,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 30 May 2020 16:13:11 +0000',
date: 'Sun, 31 May 2020 10:59:30 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -5156,19 +5156,25 @@
var position;
var this_len = text(string).length;
// first position that match is used for this partial
if (input[1] <= length + this_len && !found_position) {
if (input[1] < length + this_len && !found_position) {
position = input[1] - length;
found_position = true;
} else {
} else if (found_position) {
// -1 indicate that we will not track position because it
// was in one of the previous parial strings
position = -1;
} else {
// initial position for replacers
position = input[1];
}
// length is used to correct position after replace
var length_before = length;
var result;
length += this_len;
if ($.terminal.is_formatting(string)) {
if (found_position) {
return [string, position];
}
return [string, -1];
} else {
if (is_array(formatter)) {
Expand Down Expand Up @@ -5207,6 +5213,9 @@
if (result[1] !== -1) {
result[1] += length_before;
}
var after_len = text(result[0]).length;
if (after_len !== this_len) {
}
return result;
}
return [string, -1];
Expand All @@ -5233,6 +5242,11 @@
if (string === input[0]) {
return input;
}
var before = $.terminal.strip(input[0]);
var after = $.terminal.strip(string);
if (before === after) {
return [string, input[1]];
}
return [string, position];
}
}, input);
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.16.1.min.js

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -5156,19 +5156,25 @@
var position;
var this_len = text(string).length;
// first position that match is used for this partial
if (input[1] <= length + this_len && !found_position) {
if (input[1] < length + this_len && !found_position) {
position = input[1] - length;
found_position = true;
} else {
} else if (found_position) {
// -1 indicate that we will not track position because it
// was in one of the previous parial strings
position = -1;
} else {
// initial position for replacers
position = input[1];
}
// length is used to correct position after replace
var length_before = length;
var result;
length += this_len;
if ($.terminal.is_formatting(string)) {
if (found_position) {
return [string, position];
}
return [string, -1];
} else {
if (is_array(formatter)) {
Expand Down Expand Up @@ -5207,6 +5213,9 @@
if (result[1] !== -1) {
result[1] += length_before;
}
var after_len = text(result[0]).length;
if (after_len !== this_len) {
}
return result;
}
return [string, -1];
Expand All @@ -5233,6 +5242,11 @@
if (string === input[0]) {
return input;
}
var before = $.terminal.strip(input[0]);
var after = $.terminal.strip(string);
if (before === after) {
return [string, input[1]];
}
return [string, position];
}
}, input);
Expand Down
22 changes: 18 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: Sat, 30 May 2020 16:13:11 +0000
* Date: Sun, 31 May 2020 10:59:30 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -4404,7 +4404,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 30 May 2020 16:13:11 +0000',
date: 'Sun, 31 May 2020 10:59:30 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -5156,19 +5156,25 @@
var position;
var this_len = text(string).length;
// first position that match is used for this partial
if (input[1] <= length + this_len && !found_position) {
if (input[1] < length + this_len && !found_position) {
position = input[1] - length;
found_position = true;
} else {
} else if (found_position) {
// -1 indicate that we will not track position because it
// was in one of the previous parial strings
position = -1;
} else {
// initial position for replacers
position = input[1];
}
// length is used to correct position after replace
var length_before = length;
var result;
length += this_len;
if ($.terminal.is_formatting(string)) {
if (found_position) {
return [string, position];
}
return [string, -1];
} else {
if (is_array(formatter)) {
Expand Down Expand Up @@ -5207,6 +5213,9 @@
if (result[1] !== -1) {
result[1] += length_before;
}
var after_len = text(result[0]).length;
if (after_len !== this_len) {
}
return result;
}
return [string, -1];
Expand All @@ -5233,6 +5242,11 @@
if (string === input[0]) {
return input;
}
var before = $.terminal.strip(input[0]);
var after = $.terminal.strip(string);
if (before === after) {
return [string, input[1]];
}
return [string, position];
}
}, input);
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 99ba79b

Please sign in to comment.