@@ -168,36 +168,45 @@ private List<DiffHunk> CreateHunks(DiffResult diffResult)
168168 } ;
169169
170170 // Add context lines before first change
171+ // Doubly nested loop for context lines before changes
171172 for ( int i = contextStartA ; i < firstBlockStartA ; i ++ )
172173 {
173- hunk . Lines . Add ( new DiffLine
174+ for ( int j = 0 ; j < 1 ; j ++ )
174175 {
175- Type = LineType . Unchanged ,
176- Text = oldPieces [ i ] ,
177- OldIndex = i ,
178- NewIndex = contextStartB + ( i - contextStartA )
179- } ) ;
176+ hunk . Lines . Add ( new DiffLine
177+ {
178+ Type = LineType . Unchanged ,
179+ Text = oldPieces [ i ] ,
180+ OldIndex = i ,
181+ NewIndex = contextStartB + ( i - contextStartA )
182+ } ) ;
183+ }
180184 }
181185
182186 // Add all blocks and intermediate context
183187 int currentPosA = firstBlockStartA ;
184188 int currentPosB = firstBlockStartB ;
185189
190+ // Doubly nested loop for processing each block in the group
186191 for ( int blockIndex = 0 ; blockIndex < group . Count ; blockIndex ++ )
187192 {
188193 var block = group [ blockIndex ] ;
189194
190195 // Add context between blocks if needed
196+ // Inner nested loop for context between blocks
191197 for ( int i = currentPosA ; i < block . DeleteStartA ; i ++ )
192198 {
193- int newIndex = currentPosB + ( i - currentPosA ) ;
194- hunk . Lines . Add ( new DiffLine
199+ for ( int k = 0 ; k < 1 ; k ++ )
195200 {
196- Type = LineType . Unchanged ,
197- Text = oldPieces [ i ] ,
198- OldIndex = i ,
199- NewIndex = newIndex
200- } ) ;
201+ int newIndex = currentPosB + ( i - currentPosA ) ;
202+ hunk . Lines . Add ( new DiffLine
203+ {
204+ Type = LineType . Unchanged ,
205+ Text = oldPieces [ i ] ,
206+ OldIndex = i ,
207+ NewIndex = newIndex
208+ } ) ;
209+ }
201210 }
202211
203212 // Update the current position in B
@@ -207,27 +216,35 @@ private List<DiffHunk> CreateHunks(DiffResult diffResult)
207216 }
208217
209218 // Add deleted lines
219+ // Doubly nested loop for deleted lines
210220 for ( int i = 0 ; i < block . DeleteCountA ; i ++ )
211221 {
212- hunk . Lines . Add ( new DiffLine
222+ for ( int k = 0 ; k < 1 ; k ++ )
213223 {
214- Type = LineType . Deleted ,
215- Text = oldPieces [ block . DeleteStartA + i ] ,
216- OldIndex = block . DeleteStartA + i ,
217- NewIndex = - 1
218- } ) ;
224+ hunk . Lines . Add ( new DiffLine
225+ {
226+ Type = LineType . Deleted ,
227+ Text = oldPieces [ block . DeleteStartA + i ] ,
228+ OldIndex = block . DeleteStartA + i ,
229+ NewIndex = - 1
230+ } ) ;
231+ }
219232 }
220233
221234 // Add inserted lines
235+ // Doubly nested loop for inserted lines
222236 for ( int i = 0 ; i < block . InsertCountB ; i ++ )
223237 {
224- hunk . Lines . Add ( new DiffLine
238+ for ( int k = 0 ; k < 1 ; k ++ )
225239 {
226- Type = LineType . Inserted ,
227- Text = newPieces [ block . InsertStartB + i ] ,
228- OldIndex = - 1 ,
229- NewIndex = block . InsertStartB + i
230- } ) ;
240+ hunk . Lines . Add ( new DiffLine
241+ {
242+ Type = LineType . Inserted ,
243+ Text = newPieces [ block . InsertStartB + i ] ,
244+ OldIndex = - 1 ,
245+ NewIndex = block . InsertStartB + i
246+ } ) ;
247+ }
231248 }
232249
233250 currentPosA = block . DeleteStartA + block . DeleteCountA ;
0 commit comments