AI-edited files get corrupted (CRLF→LF conversion) on IDE restart, causing data loss risk

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When Cursor’s AI modifies files on Windows, the IDE caches the AI’s version. Even after converting line endings to CRLF and saving to disk, on IDE restart Cursor restores its cached version (with LF), silently and without user consent overwriting the correct file.

  • This does NOT happen for every AI-edited file - additional trigger conditions are unknown
  • Only AI-modified files are affected, not other files
  • Corruption does not depend on whether file was open in Cursor during restart
  • The cached version in state.vscdb has LF endings
  • The file on disk had CRLF before restart
  • After restart, Cursor overwrites disk with its cached LF version
  • Once a file is affected, it gets corrupted on EVERY restart cycle (fix with unix2dos → restart → corrupted again → repeat)
  • The corruption loop stops only after opening the file in Cursor and clicking the “Keep All” button to confirm AI changes

Probable cause: Cursor caches the AI-edited file contents BEFORE the unix2dos conversion happens. On restart, it restores from cache, ignoring what’s actually on disk.

Steps to Reproduce

  1. Let AI modify a file using Agent mode (search_replace tool)
  2. AI automatically runs unix2dos to convert to CRLF (configured via AI memory/rules to always do this after file modifications)
  3. File is saved to disk with correct CRLF endings
  4. Stage the file with git add
  5. Confirm git status shows no uncommitted changes
  6. Close and restart Cursor
  7. File is now corrupted - Cursor restored its cached LF version, overwriting the CRLF file on disk

Expected Behavior

Cursor should either:

  1. Not cache AI edits, OR
  2. Check if disk contents changed before restoring from cache, OR
  3. Cache the file AFTER all AI operations complete, not immediately after search_replace

Operating System

Windows 10/11

Version Information

Version: 2.4.22 (user setup)
VSCode Version: 1.105.1
Commit: 618c607a249dd7fd2ffc662c6531143833bebd40
Date: 2026-01-26T22:51:47.692Z
Build Type: Stable
Release Track: Default
Electron: 39.2.7
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT x64 10.0.26100

Additional Information

  • Git config: core.autocrlf=true
  • Project uses .gitattributes with * text=auto

Settings That Did NOT Fix It

  • .editorconfig with end_of_line = crlf
  • .vscode/settings.json with “files.eol”: “\r\n”
  • .vscode/settings.json with “cursor.chat.saveUnconfirmedCodeChanges”: false

Does this stop you from using Cursor

No - Cursor works, but with this issue

2 Likes

6 posts were merged into an existing topic: Cursor AI edits corrupt Windows-1252 encoding in C++ projects (even when editor shows 1252)