Describe the Bug
Summary
When instructing the AI assistant to replace the entire content of a file using the edit_file tool, the tool does not perform a simple replacement. Instead, it attempts a complex and incorrect merge between the old and new content, resulting in a corrupted file with numerous compilation errors. This behavior makes the “replace” functionality of the tool unreliable and dangerous for refactoring tasks.
Steps to Reproduce
Start with a moderately complex class file in a Flutter project (e.g., a data model with ~50-100 lines, containing methods and properties using the double type).
In the Cursor chat, provide a completely new version of the file that refactors all double properties and related methods to use the Decimal type from the decimal package.
Give the AI the explicit prompt: “Please replace the entire content of [filename] with the following code:” followed by the new code block.
Observe the edit_file tool’s execution.
Inspect the resulting file. It will not be a clean replacement but a corrupted merge of the original and the new code.
Expected Behavior
When the AI is given the instruction “Please replace the entire content of [filename] with the following code:”, the edit_file tool should discard the original file’s content completely and write the new content exactly as provided. The resulting file should be identical to the code block supplied in the prompt.
Actual Behavior
The edit_file tool performs a “diff-like” merge. It seems to analyze the old and new code and applies changes line-by-line, leading to a disastrous result when the two versions have fundamentally different structures (e.g., changing data types from double to Decimal, which refactors all related methods and properties). The output is a mix of both files, containing duplicate methods, incorrect types, and compilation errors.
Operating System
Windows 10/11
Current Cursor Version (Menu → About Cursor → Copy)
Version: 1.0.0 (user setup)
VSCode Version: 1.96.2
Commit: 53b99ce608cba35127ae3a050c1738a959750860
Date: 2025-06-04T19:44:25.253Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100
Does this stop you from using Cursor
Yes - Cursor is unusable