@@ -109,27 +109,29 @@ void AddCommentTags(SyntaxTree cu, IList<TagComment> tagComments, ITextSource fi
109109 foreach ( var comment in cu . Descendants . OfType < Comment > ( ) ) {
110110 if ( comment . CommentType == CommentType . InactiveCode )
111111 continue ;
112- int matchLength ;
113- int index = comment . Content . IndexOfAny ( TaskListTokens , 0 , out matchLength ) ;
114- if ( index > - 1 ) {
112+ string match ;
113+ if ( comment . Content . ContainsAny ( TaskListTokens , 0 , out match ) ) {
115114 if ( document == null )
116115 document = new ReadOnlyDocument ( fileContent , fileName ) ;
117116 int commentSignLength = comment . CommentType == CommentType . Documentation || comment . CommentType == CommentType . MultiLineDocumentation ? 3 : 2 ;
118117 int commentEndSignLength = comment . CommentType == CommentType . MultiLine || comment . CommentType == CommentType . MultiLineDocumentation ? 2 : 0 ;
119118 int commentStartOffset = document . GetOffset ( comment . StartLocation ) + commentSignLength ;
120119 int commentEndOffset = document . GetOffset ( comment . EndLocation ) - commentEndSignLength ;
120+ int endOffset ;
121+ int searchOffset = 0 ;
121122 do {
122- int absoluteOffset = commentStartOffset + index ;
123+ int start = commentStartOffset + searchOffset ;
124+ int absoluteOffset = document . IndexOf ( match , start , document . TextLength - start , StringComparison . Ordinal ) ;
123125 var startLocation = document . GetLocation ( absoluteOffset ) ;
124- int endOffset = Math . Min ( document . GetLineByNumber ( startLocation . Line ) . EndOffset , commentEndOffset ) ;
126+ endOffset = Math . Min ( document . GetLineByNumber ( startLocation . Line ) . EndOffset , commentEndOffset ) ;
125127 string content = document . GetText ( absoluteOffset , endOffset - absoluteOffset ) ;
126- if ( content . Length < matchLength ) {
128+ if ( content . Length < match . Length ) {
127129 // HACK: workaround parser bug with multi-line documentation comments
128130 break ;
129131 }
130- tagComments . Add ( new TagComment ( content . Substring ( 0 , matchLength ) , new DomRegion ( cu . FileName , startLocation . Line , startLocation . Column ) , content . Substring ( matchLength ) ) ) ;
131- index = comment . Content . IndexOfAny ( TaskListTokens , endOffset - commentStartOffset , out matchLength ) ;
132- } while ( index > - 1 ) ;
132+ tagComments . Add ( new TagComment ( content . Substring ( 0 , match . Length ) , new DomRegion ( cu . FileName , startLocation . Line , startLocation . Column ) , content . Substring ( match . Length ) ) ) ;
133+ searchOffset = endOffset - commentStartOffset ;
134+ } while ( comment . Content . ContainsAny ( TaskListTokens , searchOffset , out match ) ) ;
133135 }
134136 }
135137 }
0 commit comments