File deleted after rejecting edit
Resolved 💬 4 comments Opened Mar 11, 2025 by 1g0s Closed Mar 14, 2025
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 0.2.37
- Operating System: macOS 14.3
- Terminal: iTerm2
Bug Description
When declining a suggested code modification from Claude in a Python script, the entire file content gets deleted. After requesting Claude to recover the file, IntelliJ IDEA reports the file was loaded with the wrong encoding (UTF-8).
Steps to Reproduce
- Use Claude to suggest a code change in a Python script.
- Select “No” when asked to apply the change.
- Observe that the file’s entire content is removed.
- Request Claude to recover the file.
- Open the file in IntelliJ IDEA and encounter the UTF-8 encoding error.
Expected Behavior
- Declining a suggested change should leave the file unaltered.
- Recovering the file should restore valid content without causing encoding issues.
Actual Behavior
- Selecting “No” causes the file to be completely wiped.
- After recovery, IntelliJ IDEA flags the file as having the wrong encoding (UTF-8), preventing normal editing.
Additional Context
- Attached screenshot shows the IntelliJ error message.
- Issue might be related to how Claude handles file contents when discarding or restoring changes.
- Copy/Paste of code to the new file is a workaround
<img width="1434" alt="Image" src="https://github.com/user-attachments/assets/31787878-7598-43b3-8edd-e6b2c7fb43a6" />
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗