Skip to content

Commit

Permalink
Fixed word movements stopping on accented/non-latin chars
Browse files Browse the repository at this point in the history
closes #628
- expanded `WORD_CHAR_REGEX` to include full unicode list of word chars by generating the regex through XRegExp (http://xregexp.com)
  • Loading branch information
kevinansfield committed Jul 11, 2018
1 parent 9cbb2ba commit a192cdb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/js/utils/cursor/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import Range from './range';

const { FORWARD, BACKWARD } = DIRECTION;

const WORD_CHAR_REGEX = /\w|_|:/;
// generated via http://xregexp.com/ to cover chars that \w misses
// (new XRegExp('\\p{Alphabetic}|[0-9]|_|:')).toString()
const WORD_CHAR_REGEX = /[A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͅͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևְ-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-ٗٙ-ٟٮ-ۓە-ۜۡ-ۭۨ-ۯۺ-ۼۿܐ-ܿݍ-ޱߊ-ߪߴߵߺ----------------------------------------------------------------------------ൿ--------------------က---------------------------------------------------------------ᶿ-----------------------------------------ⷿ--------------ꀀ-----------------------ꦿ------------------------------------------]|[0-9]|_|:/;

function findParentSectionFromNode(renderTree, node) {
let renderNode = renderTree.findRenderNodeFromElement(
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/utils/cursor-position-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ test('#moveWord in text (backward)', (assert) => {
['abc|', '|abc'],
['ab|c', '|abc'],
['|abc', '|abc'],
['abc |', '|abc']
['abc |', '|abc'],
['abcdéf|', '|abcdéf']
];

expectations.forEach(([before, after]) => {
Expand Down

0 comments on commit a192cdb

Please sign in to comment.