@@ -136,7 +136,7 @@ private static string ToString(IList<DoubleUtf16Char> source, int start, int cou
136136 /// </summary>
137137 /// <param name="text">The text such as <see cref="Status.Text"/>, <see cref="DirectMessage.Text"/> and <see cref="User.Description"/>.</param>
138138 /// <param name="entities">The <see cref="Entities"/> instance.</param>
139- /// <returns>An <see cref="IEnumerable{ITextPart }"/> whose elements are parts of <paramref name="text"/>.</returns>
139+ /// <returns>An <see cref="IEnumerable{TextPart }"/> whose elements are parts of <paramref name="text"/>.</returns>
140140 public static IEnumerable < TextPart > EnumerateTextParts ( string text , Entities entities )
141141 {
142142 var chars = GetCodePoints ( text ) ;
@@ -150,20 +150,22 @@ public static IEnumerable<TextPart> EnumerateTextParts(string text, Entities ent
150150 /// <param name="entities">The <see cref="Entities"/> instance.</param>
151151 /// <param name="startIndex">The starting character position in code point.</param>
152152 /// <param name="endIndex">The ending character position in code point.</param>
153- /// <returns>An <see cref="IEnumerable{ITextPart }"/> whose elements are parts of <paramref name="text"/>.</returns>
153+ /// <returns>An <see cref="IEnumerable{TextPart }"/> whose elements are parts of <paramref name="text"/>.</returns>
154154 public static IEnumerable < TextPart > EnumerateTextParts ( string text , Entities entities , int startIndex , int endIndex )
155155 {
156- return EnumerateTextParts ( GetCodePoints ( text ) , entities , startIndex , endIndex ) ;
157- }
156+ var chars = GetCodePoints ( text ) ;
158157
159- private static IEnumerable < TextPart > EnumerateTextParts ( IList < DoubleUtf16Char > chars , Entities entities , int startIndex , int endIndex )
160- {
161158 if ( startIndex < 0 || startIndex >= chars . Count )
162159 throw new ArgumentOutOfRangeException ( nameof ( startIndex ) ) ;
163160
164161 if ( endIndex < startIndex || endIndex > chars . Count )
165162 throw new ArgumentOutOfRangeException ( nameof ( endIndex ) ) ;
166163
164+ return EnumerateTextParts ( chars , entities , startIndex , endIndex ) ;
165+ }
166+
167+ private static IEnumerable < TextPart > EnumerateTextParts ( IList < DoubleUtf16Char > chars , Entities entities , int startIndex , int endIndex )
168+ {
167169 if ( entities == null )
168170 {
169171 var text = ToString ( chars , startIndex , endIndex - startIndex ) ;
@@ -317,16 +319,19 @@ public static ExtendedTweetInfo GetExtendedTweetElements(this Status status)
317319
318320 var start = displayTextRange [ 0 ] ;
319321 var end = displayTextRange [ 1 ] ;
322+
323+ var entities = status . ExtendedTweet ? . Entities ?? status . Entities ;
324+
320325 return new ExtendedTweetInfo
321326 {
322327 TweetText = EnumerateTextParts (
323328 status . FullText ?? status . ExtendedTweet ? . FullText ?? status . Text ,
324- status . Entities ,
329+ entities ,
325330 start , end ) . ToArray ( ) ,
326- HiddenPrefix = status . Entities ? . UserMentions == null ? new UserMentionEntity [ 0 ]
327- : status . Entities . UserMentions . Where ( x => x . Indices [ 0 ] < start ) . ToArray ( ) ,
328- HiddenSuffix = ( status . Entities ? . Urls ?? Enumerable . Empty < UrlEntity > ( ) )
329- . Concat ( status . Entities ? . Media ?? Enumerable . Empty < UrlEntity > ( ) )
331+ HiddenPrefix = entities ? . UserMentions == null ? new UserMentionEntity [ 0 ]
332+ : entities . UserMentions . Where ( x => x . Indices [ 0 ] < start ) . ToArray ( ) ,
333+ HiddenSuffix = ( entities ? . Urls ?? Enumerable . Empty < UrlEntity > ( ) )
334+ . Concat ( entities ? . Media ?? Enumerable . Empty < UrlEntity > ( ) )
330335 . Where ( x => x . Indices [ 0 ] >= end ) . ToArray ( )
331336 } ;
332337 }
0 commit comments