You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/06/02 03:36:36 UTC

[1/9] incubator-weex git commit: * [ios] use intersectionRange compare

Repository: incubator-weex
Updated Branches:
  refs/heads/0.13-dev d273d679a -> 311042242


* [ios] use intersectionRange compare


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/7274bdd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/7274bdd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/7274bdd7

Branch: refs/heads/0.13-dev
Commit: 7274bdd726451deb8257c96d646ce02259e89419
Parents: 9778415
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 1 15:37:04 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 10:27:00 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7274bdd7/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index 90ab4ce..deeddd6 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -748,9 +748,10 @@ do {\
         NSAttributedString * lastLineText = nil;
         NSRange lastLineTextRange = WXNSRangeFromCFRange(CTLineGetStringRange(lastLine));
         NSRange attributeStringRange = NSRangeFromString(attributedString.string);
-        if (!NSEqualRanges(NSUnionRange(lastLineTextRange, attributeStringRange), attributeStringRange)) {
+        NSRange interSectionRange = NSIntersectionRange(lastLineTextRange, attributeStringRange);
+        if (!NSEqualRanges(interSectionRange, lastLineTextRange)) {
             // out of bounds
-            lastLineTextRange = NSMakeRange(attributeStringRange.location, attributeStringRange.length);
+            lastLineTextRange = interSectionRange;
         }
         lastLineText = [attributedString attributedSubstringFromRange: lastLineTextRange];
         if (!lastLineText) {


[6/9] incubator-weex git commit: + [ios] fix bug: when add IndicatorView lazy . the IndicatorView can not create in slider successfully

Posted by ac...@apache.org.
+ [ios] fix bug: when add IndicatorView  lazy . the IndicatorView can not create in slider successfully


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/8a1653c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/8a1653c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/8a1653c0

Branch: refs/heads/0.13-dev
Commit: 8a1653c0cbf382a543bde5b9ac431b73b0d24e2c
Parents: 7274bdd
Author: 齐山 <su...@163.com>
Authored: Thu Jun 1 21:43:39 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 11:09:51 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m | 1 +
 ios/sdk/WeexSDK/Sources/Component/WXSliderComponent.m      | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8a1653c0/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
index 3b8adf8..3265308 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
@@ -431,6 +431,7 @@ typedef NS_ENUM(NSInteger, Direction) {
         if ([view isKindOfClass:[WXIndicatorView class]]) {
             ((WXIndicatorComponent *)subcomponent).delegate = self;
             [recycleSliderView addSubview:view];
+            [self setIndicatorView:(WXIndicatorView *)view];
             return;
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8a1653c0/ios/sdk/WeexSDK/Sources/Component/WXSliderComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXSliderComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXSliderComponent.m
index 1077bc8..f6451cd 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXSliderComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXSliderComponent.m
@@ -449,6 +449,7 @@
         if ([view isKindOfClass:[WXIndicatorView class]]) {
             ((WXIndicatorComponent *)subcomponent).delegate = self;
             [sliderView addSubview:view];
+            [self setIndicatorView:(WXIndicatorView *)view];
             return;
         }
         


[7/9] incubator-weex git commit: + [ios] fixbug: cycle slider

Posted by ac...@apache.org.
+ [ios] fixbug: cycle slider


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a4cc8dfd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a4cc8dfd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a4cc8dfd

Branch: refs/heads/0.13-dev
Commit: a4cc8dfd9745aeb3efc4eabbffd1a00e771d5067
Parents: 8a1653c
Author: 齐山 <su...@163.com>
Authored: Fri May 26 18:03:48 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 11:10:04 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a4cc8dfd/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
index 3265308..517af72 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
@@ -586,9 +586,10 @@ typedef NS_ENUM(NSInteger, Direction) {
 
 - (void)recycleSliderView:(WXRecycleSliderView *)recycleSliderView didScrollToItemAtIndex:(NSInteger)index
 {
-    self.currentIndex = index;
-    if (_sliderChangeEvent) {
+    
+    if (_sliderChangeEvent && index != self.currentIndex) {
         [self fireEvent:@"change" params:@{@"index":@(index)} domChanges:@{@"attrs": @{@"index": @(index)}}];
+        self.currentIndex = index;
     }
 }
 


[9/9] incubator-weex git commit: Merge branch '0.13-dev' of https://github.com/acton393/incubator-weex into wip-us-0.13-dev

Posted by ac...@apache.org.
Merge branch '0.13-dev' of https://github.com/acton393/incubator-weex into wip-us-0.13-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/31104224
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/31104224
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/31104224

Branch: refs/heads/0.13-dev
Commit: 311042242f3718daa8ed6a217e7d156345f30960
Parents: d273d67 1308ff1
Author: acton393 <zh...@gmail.com>
Authored: Fri Jun 2 11:35:53 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 11:35:53 2017 +0800

----------------------------------------------------------------------
 .../Sources/Component/WXCycleSliderComponent.m  |  6 ++--
 .../Sources/Component/WXSliderComponent.m       |  1 +
 .../WeexSDK/Sources/Component/WXTextComponent.m | 34 ++++++++++++++++----
 .../WeexSDK/Sources/Events/WXComponent+Events.m |  8 +++++
 4 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/31104224/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/31104224/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
----------------------------------------------------------------------


[3/9] incubator-weex git commit: * [ios] try to fix text crash

Posted by ac...@apache.org.
* [ios] try to fix text crash


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b1070991
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b1070991
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b1070991

Branch: refs/heads/0.13-dev
Commit: b1070991edd41a2e78eb55d204a2df16efb83d4d
Parents: 3a98c09
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 1 14:47:54 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 10:27:00 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m  | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b1070991/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index d370964..f560aef 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -349,9 +349,9 @@ do {\
     });
 }
 
-- (NSMutableAttributedString *)buildCTAttributeString {
-    
-    NSString *string = [self text] ?: @"";
+- (NSMutableAttributedString *)buildCTAttributeString
+{
+    NSMutableString *string = [NSMutableString stringWithFormat:@"%@", [self text] ?: @""];
     NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
     if (_color) {
         [attributedString addAttribute:NSForegroundColorAttributeName value:_color range:NSMakeRange(0, string.length)];
@@ -745,7 +745,18 @@ do {\
         // default truncationType is kCTLineTruncationEnd
         CTLineTruncationType truncationType = kCTLineTruncationEnd;
         NSAttributedString *attributedString = [self buildCTAttributeString];
-        NSAttributedString * lastLineText = [attributedString attributedSubstringFromRange: WXNSRangeFromCFRange(CTLineGetStringRange(lastLine))];
+        NSAttributedString * lastLineText = nil;
+        @try {
+            lastLineText = [attributedString attributedSubstringFromRange: WXNSRangeFromCFRange(CTLineGetStringRange(lastLine))];
+        } @catch (NSException *exception) {
+            lastLineText = attributedString;
+        } @finally {
+            if (!lastLineText) {
+                lastLineText = attributedString;
+            }
+            //nothing
+        }
+        
         NSMutableAttributedString *mutableLastLineText = lastLineText.mutableCopy;
         [mutableLastLineText appendAttributedString:truncationToken];
         CTLineRef ctLastLineExtend = CTLineCreateWithAttributedString((__bridge CFAttributedStringRef)mutableLastLineText);


[8/9] incubator-weex git commit: * [ios] remove notification for text if needs

Posted by ac...@apache.org.
* [ios] remove notification for text if needs


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/1308ff19
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/1308ff19
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/1308ff19

Branch: refs/heads/0.13-dev
Commit: 1308ff195c4710a4aed7689fbb275f2aae31895a
Parents: a4cc8df
Author: acton393 <zh...@gmail.com>
Authored: Fri Jun 2 11:30:03 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 11:30:03 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/1308ff19/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index deeddd6..f3fbd93 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -116,6 +116,8 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
     CGFloat _lineHeight;
     CGFloat _letterSpacing;
     BOOL _truncationLine; // support trunk tail
+    
+    BOOL _needsRemoveObserver;
 }
 
 + (void)setRenderUsingCoreText:(BOOL)usingCoreText
@@ -138,6 +140,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
     self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance];
     if (self) {
         // just for coretext and textkit render replacement
+        _needsRemoveObserver = NO;
         if ([attributes objectForKey:@"coretext"]) {
             _useCoreTextAttr = [WXConvert NSString:attributes[@"coretext"]];
         } else {
@@ -169,7 +172,9 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
 
 - (void)dealloc
 {
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    if (_needsRemoveObserver) {
+        [[NSNotificationCenter defaultCenter] removeObserver:self name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
+    }
 }
 
 #define WX_STYLE_FILL_TEXT(key, prop, type, needLayout)\
@@ -365,6 +370,7 @@ do {\
         //custom localSrc is cached
         if (!fontLocalSrc && fontSrc) {
             // if use custom font, when the custom font download finish, refresh text.
+            _needsRemoveObserver = YES;
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repaintText:) name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
         }
     }
@@ -443,6 +449,7 @@ do {\
         //custom localSrc is cached
         if (!fontLocalSrc && fontSrc) {
             // if use custom font, when the custom font download finish, refresh text.
+            _needsRemoveObserver = YES;
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repaintText:) name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
         }
     }


[5/9] incubator-weex git commit: * [ios] remove gesture in case of crash

Posted by ac...@apache.org.
* [ios] remove gesture in case of crash


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/99a9bbd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/99a9bbd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/99a9bbd9

Branch: refs/heads/0.13-dev
Commit: 99a9bbd92d48c7afd0a8f27ba14d8a314dc4f6a0
Parents: 41ee7b2
Author: acton393 <zh...@gmail.com>
Authored: Thu May 25 21:46:09 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 10:27:00 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/99a9bbd9/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
index 85c767c..7dd496b 100644
--- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
+++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
@@ -270,6 +270,8 @@ if ([removeEventName isEqualToString:@#eventName]) {\
 - (void)removeClickEvent
 {
     if (_tapGesture) {
+        [_tapGesture removeTarget:self action:@selector(onClick:)];
+        [self.view removeGestureRecognizer:_tapGesture];
         _tapGesture.delegate = nil;
         _tapGesture = nil;
     }
@@ -341,6 +343,8 @@ if ([removeEventName isEqualToString:@#eventName]) {\
     }
   
     for (UISwipeGestureRecognizer *recognizer in _swipeGestures) {
+        [recognizer removeTarget:self action:@selector(onSwipe:)];
+        [self.view removeGestureRecognizer:recognizer];
         recognizer.delegate = nil;
     }
     
@@ -394,6 +398,8 @@ if ([removeEventName isEqualToString:@#eventName]) {\
 - (void)removeLongPressEvent
 {
     if (_longPressGesture) {
+        [_longPressGesture removeTarget:self action:@selector(onLongPress:)];
+        [self.view removeGestureRecognizer:_longPressGesture];
         _longPressGesture.delegate = nil;
         _longPressGesture = nil;
     }
@@ -539,6 +545,8 @@ if ([removeEventName isEqualToString:@#eventName]) {\
         && !_listenPanStart && !_listenPanMove && !_listenPanEnd
         && !_listenHorizontalPan && !_listenVerticalPan
         ) {
+        [_panGesture removeTarget:self action:@selector(onPan:)];
+        [self.view removeGestureRecognizer:_panGesture];
         _panGesture.delegate = nil;
         _panGesture = nil;
     }


[4/9] incubator-weex git commit: * [ios] fix text description about coretext

Posted by ac...@apache.org.
* [ios] fix text description about coretext


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/3a98c094
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/3a98c094
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/3a98c094

Branch: refs/heads/0.13-dev
Commit: 3a98c094aa2d3667d13e4730030e6dd0584e0820
Parents: 99a9bbd
Author: acton393 <zh...@gmail.com>
Authored: Fri May 26 11:58:24 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 10:27:00 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3a98c094/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index e6be027..d370964 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -64,7 +64,11 @@
 {
     NSString *superDescription = super.description;
     NSRange semicolonRange = [superDescription rangeOfString:@";"];
-    NSString *replacement = [NSString stringWithFormat:@"; text: %@; frame:%f,%f,%f,%f", _textStorage.string, self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height];
+    NSString * content = _textStorage.string;
+    if ([(WXTextComponent*)self.wx_component useCoreText]) {
+        content = [(WXTextComponent*)self.wx_component valueForKey:@"_text"];
+    }
+    NSString *replacement = [NSString stringWithFormat:@"; text: %@; frame:%f,%f,%f,%f", content, self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height];
     return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
 }
 


[2/9] incubator-weex git commit: * [ios] use range compare

Posted by ac...@apache.org.
* [ios] use range compare


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9778415e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9778415e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9778415e

Branch: refs/heads/0.13-dev
Commit: 9778415ebbaac9e0004a01d2e9843c062594f284
Parents: b107099
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 1 15:26:30 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jun 2 10:27:00 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m    | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9778415e/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index f560aef..90ab4ce 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -746,17 +746,16 @@ do {\
         CTLineTruncationType truncationType = kCTLineTruncationEnd;
         NSAttributedString *attributedString = [self buildCTAttributeString];
         NSAttributedString * lastLineText = nil;
-        @try {
-            lastLineText = [attributedString attributedSubstringFromRange: WXNSRangeFromCFRange(CTLineGetStringRange(lastLine))];
-        } @catch (NSException *exception) {
+        NSRange lastLineTextRange = WXNSRangeFromCFRange(CTLineGetStringRange(lastLine));
+        NSRange attributeStringRange = NSRangeFromString(attributedString.string);
+        if (!NSEqualRanges(NSUnionRange(lastLineTextRange, attributeStringRange), attributeStringRange)) {
+            // out of bounds
+            lastLineTextRange = NSMakeRange(attributeStringRange.location, attributeStringRange.length);
+        }
+        lastLineText = [attributedString attributedSubstringFromRange: lastLineTextRange];
+        if (!lastLineText) {
             lastLineText = attributedString;
-        } @finally {
-            if (!lastLineText) {
-                lastLineText = attributedString;
-            }
-            //nothing
         }
-        
         NSMutableAttributedString *mutableLastLineText = lastLineText.mutableCopy;
         [mutableLastLineText appendAttributedString:truncationToken];
         CTLineRef ctLastLineExtend = CTLineCreateWithAttributedString((__bridge CFAttributedStringRef)mutableLastLineText);