From 348d2355c620e4504673dd5d09c734340741146f Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 7 Jun 2013 14:26:46 +0100 Subject: [PATCH] Fix conversion of byte to grapheme offsets/lengths Missed one case in ve.ce.Docuemnt#getNodeAndOffset. Bug: 49246 Change-Id: Iff1dfb90130685bb710821f8386cfa2f296f2f95 --- demos/ve/pages/multibyte.html | 2 +- modules/ve/ce/ve.ce.Document.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/demos/ve/pages/multibyte.html b/demos/ve/pages/multibyte.html index e488ec1e0a..979b3125ab 100644 --- a/demos/ve/pages/multibyte.html +++ b/demos/ve/pages/multibyte.html @@ -1,5 +1,5 @@

12𨋢456789𨋢bc

-

「𨋢」字響香港衍生出好多新詞,好似:𨋢

+

「𨋢」字響香港衍生出好多新詞,好似:𨋢香港 abc

abc

one c̀ombining accent

two ç̀ombining accents

diff --git a/modules/ve/ce/ve.ce.Document.js b/modules/ve/ce/ve.ce.Document.js index 6bcedceeeb..29d4108436 100644 --- a/modules/ve/ce/ve.ce.Document.js +++ b/modules/ve/ce/ve.ce.Document.js @@ -146,7 +146,8 @@ ve.ce.Document.prototype.getNodeAndOffset = function ( offset ) { } item = current[0][current[1]]; if ( item.nodeType === Node.TEXT_NODE ) { - length = item.textContent.length; + // offset, startOffset and length are all data model lengths (not byte lengths) + length = ve.getClusterOffset( item.textContent, item.textContent.length ); if ( offset >= startOffset && offset <= startOffset + length ) { return { node: item,