Skip to content

Conversation

@hashemix
Copy link
Member

📌 Summary

This PR fixes a potential panic in the apply_file_edits function caused by attempting to access an out-of-range slice when the old_text in an EditOperation has more lines than the file content.

The issue was identified in #19 where a file with 2 lines and an edit with 41 lines triggered a range end index 41 out of range for slice of length 2 panic.

🔍 Related Issues

✨ Changes Made

  • Added a check in apply_file_edits to verify that old_lines.len() does not exceed content_lines.len() before the line-by-line matching loop.
  • Returns an Err with a descriptive message if the edit operation is too large, preventing the panic.
  • Added a test case to validate the new error handling behavior.

@hashemix hashemix changed the title fix: improved apply_file_edits by adding bounds check for edit operation fix: file edit operation by adding bounds check May 29, 2025
@hashemix hashemix merged commit 4fedd50 into main May 29, 2025
11 checks passed
@hashemix hashemix mentioned this pull request May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust panic at Claude Desktop Start

2 participants