@@ -312,8 +312,8 @@ const apply_diff_patch = (
312312 replace_chunks . pop ( )
313313 }
314314
315- if ( search_chunks . length != 0 || replace_chunks . length != 0 ) // Don't add search or replace blocks if empty
316- {
315+ if ( search_chunks . length != 0 || replace_chunks . length != 0 ) {
316+ // Don't add search or replace blocks if empty
317317 // Add the final search block to the searchReplaceBlocks
318318 // This is crucial for diffs that only have deletions
319319 search_replace_blocks . push (
@@ -343,24 +343,24 @@ const apply_diff_patch = (
343343 j ++
344344 ) {
345345 // Create a chunk of lines from originalCodeLinesNormalized
346- const chunk = original_code_lines_normalized . slice (
347- j ,
348- j + search_replace_block . search_lines . length
349- )
350- const chunk_string = chunk . map ( ( line ) => line . value ) . join ( '' )
346+ // const chunk = original_code_lines_normalized.slice(
347+ // j,
348+ // j + search_replace_block.search_lines.length
349+ // )
350+ // const chunk_string = chunk.map((line) => line.value).join('')
351351
352352 // console.log('Chunk string: ' + chunk_string);
353353
354354 // If we have no search lines and only replace lines and our previous found index is 0
355355 // assume we are at the start of the file and set the search block start index to 0
356356 // This is a special case when a patch hunk starts with one or more + lines and no context lines
357- if ( search_replace_block . search_lines . length == 0 && previous_found_index == 0 )
358- {
357+ if (
358+ search_replace_block . search_lines . length == 0 &&
359+ previous_found_index == 0
360+ ) {
359361 search_replace_block . search_block_start_index = - 1 // insert at the start of the file
360362 found = true
361- }
362- else
363- {
363+ } else {
364364 // Create a chunk of lines from originalCodeLinesNormalized
365365 const chunk = original_code_lines_normalized . slice (
366366 j ,
@@ -372,7 +372,7 @@ const apply_diff_patch = (
372372 //console.log('Chunk string: ' + chunk_string);
373373 //console.log('Previous found index: ' + previous_found_index);
374374 //console.log('Chunk: ' + JSON.stringify(chunk, null, 2));
375-
375+
376376 // Check if the chunk matches the search string
377377 if ( chunk_string == search_string ) {
378378 // Check if found index is greater than the previous found index
@@ -397,7 +397,7 @@ const apply_diff_patch = (
397397 if ( ! found ) {
398398 search_replace_block . search_block_start_index = - 2 // Not found
399399
400- const error_message = `Search block not found: ${ search_string } `
400+ const error_message = `Search block not found: ${ search_string } `
401401 Logger . error ( {
402402 function_name : 'apply_diff_patch' ,
403403 message : error_message
@@ -426,7 +426,8 @@ const apply_diff_patch = (
426426
427427 // Iterrate over the valid blocks and apply them
428428 for ( const block of valid_blocks ) {
429- const start_index = block . get_start_index ( ) == - 1 ? 0 : block . get_start_index ( ) // When -1, insert at the start of the file
429+ const start_index =
430+ block . get_start_index ( ) == - 1 ? 0 : block . get_start_index ( ) // When -1, insert at the start of the file
430431 const search_count = block . get_search_count ( )
431432 const replacement_content = block . replace_lines // These are original lines
432433
0 commit comments