Skip to content

Commit

Permalink
Word boundary search update (fabricjs#5788)
Browse files Browse the repository at this point in the history
Update to check in grapheme text rather to normal text
  • Loading branch information
durga598 authored and asturur committed Jul 13, 2019
1 parent bc29917 commit 5b641c0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/mixins/itext_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
index++;
}
}
while (/\S/.test(this._text[index]) && index < this.text.length) {
while (/\S/.test(this._text[index]) && index < this._text.length) {
offset++;
index++;
}
Expand Down Expand Up @@ -258,7 +258,7 @@
findLineBoundaryRight: function(startFrom) {
var offset = 0, index = startFrom;

while (!/\n/.test(this._text[index]) && index < this.text.length) {
while (!/\n/.test(this._text[index]) && index < this._text.length) {
offset++;
index++;
}
Expand All @@ -273,13 +273,13 @@
* @return {Number} Index of the beginning or end of a word
*/
searchWordBoundary: function(selectionStart, direction) {
var index = this._reSpace.test(this.text.charAt(selectionStart)) ? selectionStart - 1 : selectionStart,
_char = this.text.charAt(index),
var index = this._reSpace.test(this._text[selectionStart]) ? selectionStart - 1 : selectionStart,
_char = this._text[index],
reNonWord = /[ \n\.,;!\?\-]/;

while (!reNonWord.test(_char) && index > 0 && index < this.text.length) {
while (!reNonWord.test(_char) && index > 0 && index < this._text.length) {
index += direction;
_char = this.text.charAt(index);
_char = this._text[index];
}
if (reNonWord.test(_char) && _char !== '\n') {
index += direction === 1 ? 0 : 1;
Expand Down

0 comments on commit 5b641c0

Please sign in to comment.