Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions src/core/diff/strategies/multi-file-search-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ Search/Replace content:
<file>
<path>eg.file.py</path>
<diff>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment here explaining why CDATA sections are used, something like:

Suggested change
<diff>
<diff>
<!-- Using CDATA to properly escape special characters that would otherwise cause XML parsing errors (see issue #4852) -->
<content><![CDATA[

This would help future developers understand the rationale.

<content>
\`\`\`
<content><![CDATA[
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The CDATA section should be properly indented to match the XML structure. Consider adding appropriate indentation before the opening CDATA tag to maintain consistent formatting with the rest of the XML.

Suggested change
<content><![CDATA[
<content>
<![CDATA[

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test coverage for this CDATA implementation. Could we add a test case in multi-search-replace.spec.ts that specifically verifies XML content with special characters (like <<<<<<<, =======, >>>>>>>) wrapped in CDATA sections parses correctly?

<<<<<<< SEARCH
def calculate_total(items):
total = 0
Expand All @@ -152,8 +151,7 @@ def calculate_total(items):
"""Calculate total with 10% markup"""
return sum(item * 1.1 for item in items)
>>>>>>> REPLACE
\`\`\`
</content>
]]></content>
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The closing CDATA section should be properly indented to match the XML structure. Consider adding appropriate indentation before the closing tags to maintain consistent formatting with the rest of the XML.

Suggested change
]]></content>
]]></content>

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the inline CDATA formatting intentional? For better readability, you might consider:

Suggested change
]]></content>
<content>
<![CDATA[
<<<<<<< SEARCH
def calculate_total(items):
total = 0
for item in items:
total += item
return total
=======
def calculate_total(items):
"""Calculate total with 10% markup"""
return sum(item * 1.1 for item in items)
>>>>>>> REPLACE
]]>
</content>

This would make the CDATA boundaries more visually distinct.

</diff>
</file>
</args>
Expand All @@ -165,46 +163,40 @@ Search/Replace content with multi edits across multiple files:
<file>
<path>eg.file.py</path>
<diff>
<content>
\`\`\`
<content><![CDATA[
<<<<<<< SEARCH
def calculate_total(items):
sum = 0
=======
def calculate_sum(items):
sum = 0
>>>>>>> REPLACE
\`\`\`
</content>
]]></content>
</diff>
<diff>
<content>
\`\`\`
<content><![CDATA[
<<<<<<< SEARCH
total += item
return total
=======
sum += item
return sum
>>>>>>> REPLACE
\`\`\`
</content>
]]></content>
</diff>
</file>
<file>
<path>eg.file2.py</path>
<diff>
<content>
\`\`\`
<content><![CDATA[
<<<<<<< SEARCH
def greet(name):
return "Hello " + name
=======
def greet(name):
return f"Hello {name}!"
>>>>>>> REPLACE
\`\`\`
</content>
]]></content>
</diff>
</file>
</args>
Expand Down
Loading