BathyScapheで画像のインラインプレビューを可能にするプラグイン
Revisão | a58185f4049019b6dcc070cd52fa94b81e7256d1 (tree) |
---|---|
Hora | 2014-02-02 12:11:08 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
[Fix] 連続したリンクをクリックすると複数のリンクが開かれる問題を解消
@@ -132,18 +132,26 @@ static NSString *ThumbnailSizeKey = @"com.masakih.BSInlinePreviewer.thumbnailSiz | ||
132 | 132 | NSTextStorage *ts = [self targetTextStorage]; |
133 | 133 | |
134 | 134 | NSRange limit; |
135 | - if(charIndex_ > 100) { | |
136 | - limit = NSMakeRange(charIndex_ - 100, 200); | |
135 | + const NSInteger searchLength = 200; | |
136 | + if(charIndex_ > searchLength / 2) { | |
137 | + limit = NSMakeRange(charIndex_ - searchLength / 2, searchLength); | |
137 | 138 | } else { |
138 | - limit = NSMakeRange(0, 200); | |
139 | + limit = NSMakeRange(0, searchLength); | |
139 | 140 | } |
140 | 141 | NSUInteger over = NSMaxRange(limit) - [ts length]; |
141 | 142 | if(over > 0) { |
142 | 143 | limit.length -= over; |
143 | 144 | } |
144 | 145 | NSArray *links = [self linksForRange:limit]; |
145 | - | |
146 | - [self downloadAndInsertImages:links]; | |
146 | + | |
147 | + NSArray *array = nil; | |
148 | + for(BSILinkInfomation *info in links) { | |
149 | + if(NSLocationInRange(charIndex_, info.range)) { | |
150 | + array = @[info]; | |
151 | + break; | |
152 | + } | |
153 | + } | |
154 | + if(array) [self downloadAndInsertImages:array]; | |
147 | 155 | |
148 | 156 | return YES; |
149 | 157 | } |