From a937ad22f74f5bb0c0a452493b74ba52b89a4822 Mon Sep 17 00:00:00 2001 From: Rob Moen Date: Thu, 17 May 2012 13:17:18 -0700 Subject: [PATCH] Fix getAnnotatedRange to return propper contained range. Fixed tests Change-Id: I305eb81644fb3c804455b4fc13bdabcce97ea471 --- modules/ve2/dm/ve.dm.Document.js | 3 +-- tests/ve2/dm/ve.dm.Document.test.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/ve2/dm/ve.dm.Document.js b/modules/ve2/dm/ve.dm.Document.js index 4e38db6e68..0959f4a39d 100644 --- a/modules/ve2/dm/ve.dm.Document.js +++ b/modules/ve2/dm/ve.dm.Document.js @@ -412,11 +412,10 @@ ve.dm.Document.prototype.getAnnotatedRangeFromOffset = function ( offset, annota } } while ( end < this.data.length ) { - end++; if ( this.offsetContainsAnnotation(end, annotation ) === false ) { - end--; break; } + end++; } return new ve.Range( start, end ); }; diff --git a/tests/ve2/dm/ve.dm.Document.test.js b/tests/ve2/dm/ve.dm.Document.test.js index 21a6c46514..7dc667b48d 100644 --- a/tests/ve2/dm/ve.dm.Document.test.js +++ b/tests/ve2/dm/ve.dm.Document.test.js @@ -382,7 +382,7 @@ test( 'getAnnotatedRangeFromOffset', 1, function(){ ], 'annotation': { 'type': 'bold' }, 'offset': 3, - 'expected': new ve.Range( 1, 4 ) + 'expected': new ve.Range( 1, 5 ) }, { 'msg': 'a linked', @@ -410,7 +410,7 @@ test( 'getAnnotatedRangeFromOffset', 1, function(){ ], 'annotation': { 'type': 'link/internal' }, 'offset': 3, - 'expected': new ve.Range( 3, 6 ) + 'expected': new ve.Range( 3, 7 ) } ];