@@ -241,28 +241,28 @@ Only use a single line of '=======' between search and replacement content, beca
241241 Ensures the first marker starts at the beginning of the file or right after a newline.
242242
243243 2. (?<!\\)<<<<<<< SEARCH\s*\n
244- Matches the line " <<<<<<< SEARCH" (ignoring any trailing spaces) – the negative lookbehind makes sure it isn' t escaped.
244+ Matches the line “ <<<<<<< SEARCH” (ignoring any trailing spaces) – the negative lookbehind makes sure it isn’ t escaped.
245245
246246 3. ((?:\:start_line:\s*(\d+)\s*\n))?
247- Optionally matches a " :start_line:" line. The outer capturing group is group 1 and the inner (\d+) is group 2.
247+ Optionally matches a “ :start_line:” line. The outer capturing group is group 1 and the inner (\d+) is group 2.
248248
249249 4. ((?:\:end_line:\s*(\d+)\s*\n))?
250- Optionally matches a " :end_line:" line. Group 3 is the whole match and group 4 is the digits.
250+ Optionally matches a “ :end_line:” line. Group 3 is the whole match and group 4 is the digits.
251251
252252 5. ((?<!\\)-------\s*\n)?
253- Optionally matches the " -------" marker line (group 5).
253+ Optionally matches the “ -------” marker line (group 5).
254254
255255 6. ([\s\S]*?)(?:\n)?
256- Non‐greedy match for the " search content" (group 6) up to the next marker.
256+ Non‐greedy match for the “ search content” (group 6) up to the next marker.
257257
258258 7. (?:(?<=\n)(?<!\\)=======\s*\n)
259- Matches the " =======" marker on its own line.
259+ Matches the “ =======” marker on its own line.
260260
261261 8. ([\s\S]*?)(?:\n)?
262- Non‐greedy match for the " replace content" (group 7).
262+ Non‐greedy match for the “ replace content” (group 7).
263263
264264 9. (?:(?<=\n)(?<!\\)>>>>>>> REPLACE)(?=\n|$)
265- Matches the final " >>>>>>> REPLACE" marker on its own line (and requires a following newline or the end of file).
265+ Matches the final “ >>>>>>> REPLACE” marker on its own line (and requires a following newline or the end of file).
266266 */
267267
268268 let matches = [
@@ -300,9 +300,11 @@ Only use a single line of '=======' between search and replacement content, beca
300300 searchContent = this . unescapeMarkers ( searchContent )
301301 replaceContent = this . unescapeMarkers ( replaceContent )
302302
303- // Strip line numbers from search and replace content
304- searchContent = stripLineNumbers ( searchContent )
305- replaceContent = stripLineNumbers ( replaceContent )
303+ // Strip line numbers from search and replace content if every line starts with a line number
304+ if ( everyLineHasLineNumbers ( searchContent ) && everyLineHasLineNumbers ( replaceContent ) ) {
305+ searchContent = stripLineNumbers ( searchContent )
306+ replaceContent = stripLineNumbers ( replaceContent )
307+ }
306308
307309 // Validate that search and replace content are not identical
308310 if ( searchContent === replaceContent ) {
0 commit comments