Agent regresses JavaDoc and corrupts line endings during multi-file refactors

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Conversation ID: ec14702a-7125-494b-83b4-9b5b2853c788
[User: attach Request ID from Cursor UI if available]
Environment:

  • Cursor Agent mode, Windows 10
  • Project: Java/Spring Boot (Maven), refactor plan execution
    Issue 1 — Unrequested deletion of existing comments
    When executing a structured refactor plan, the agent replaced entire Java
    source files via Write tool instead of minimal StrReplace diffs. Collateral
    damage included removal of existing JavaDoc on methods/fields and inline
    comments (e.g. TcpClientService, AuthService, MessageReplyService). The
    user’s plan did not ask to remove documentation.
    Issue 2 — File content corrupted with extra blank lines per line
    After Write operations, several .java files exhibited an alternating pattern
    (every content line followed by an empty line), roughly doubling file length.
    Subsequent agent attempts to “fix” this (regex collapse of \n\n and
    heuristic re-formatting) removed legitimate blank lines from the original
    codebase (e.g. blank lines between @Autowired fields, import groups).
    Expected:
  • Preserve existing comments unless explicitly asked to change them
  • Preserve original formatting/blank lines when making logic-only changes
  • Prefer surgical edits (StrReplace) over full-file Write for established files
    Impact:
    User lost significant time reviewing and asking for comment/format restoration
    unrelated to the actual protocol alignment task.

Steps to Reproduce

Open a Java project that already has JavaDoc and a consistent blank-line style.
In Agent mode, submit a refactor plan that says: change behavior only; do not remove comments; do not reformat.
Observe the Agent rewriting multiple existing source files with full-file Write instead of small surgical edits.
Inspect the diff:
Issue A: Method/field JavaDoc and inline comments are deleted (not requested).
Issue B: Some files show an alternating pattern (content line + empty line), roughly doubling line count.

Operating System

Windows 10/11

Version Information

Version: 3.17.21 (user setup)
VS Code Extension API: 1.128.0
Commit: 8f2a112cb2845a97b75fd932ea5c470579ca4060
Date: 2026-08-25T01:05:08.089Z
Layout: Agent Window
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.291
OS: Windows_NT x64 10.0.22631

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey, thanks for the detailed report.

About the doubled blank lines, this is a known issue we’re tracking. It shows up when the agent does a full-file rewrite on files with CRLF line endings on Windows. Each line break ends up with a duplicated carriage return, and you get a real blank line between lines of code on disk. The same symptom is described here: 161703 Agent Write tool inserts blank line between every line in file contents and 168205 Agent adding new lines. I added your report to what we’re already tracking. I can’t share an ETA yet, but I’ll post an update if I hear anything.

How to clean up an affected file:

  • Open the file, click the line ending indicator in the bottom-right corner of the status bar, switch to LF, and save. If your project needs CRLF, switch back after.
  • Or run your usual formatter on the file. That also removes the extra lines.
  • Just don’t ask the agent to fix this with regex passes on \n\n. That’s exactly what removed your legitimate blank lines.

About the removed JavaDoc and comments, that happens when the model chooses to rewrite the whole file instead of doing targeted edits, and it can lose comments in the process. Instructions in rules help, but they don’t guarantee the result. For larger refactors, it’s better to split the plan into smaller steps and review each file diff before you accept.

If you hit this again, please send the Request ID from the affected chat right-side chat context menu in the top-right corner > Copy Request ID. That’ll help us narrow down the details.