Cursor keeps deleting half my code randomly

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When I close the cursor program and open it the next day, sometimes, not always, it just deletes half the code. To get it back, I need to rewind to an earlier message, that fixes and restores it all. Additionally, right now when I close the program, it just deletes all of the code instead of half. Everything is recoverable by rewinding to an earlier state but it is really annoying.

Steps to Reproduce

I just close the program, either clicking the X button in the window or going file - exit. I tried doing it 2 times and it happened both times. Trying the next day is more random whether it works or not. Clicking file - exit seems to reduce the chances of the bug but unsure.

Operating System

Windows 10/11

Version Information

Version: 3.6.31 (user setup)
VS Code Extension API: 1.105.1
Commit: 81fcf2931d7687b4ff3f3017858d0c6dee7e2a60
Date: 2026-05-31T17:46:29.630Z
Layout: glass
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
xterm.js: 6.1.0-beta.220
OS: Windows_NT x64 10.0.26200

Additional Information

This could become a serious problem if I forget to notice that half the code is missing and continue adding updates to it.

Does this stop you from using Cursor

No - Cursor works, but with this issue

What you’re describing - code going missing after close/reopen but recovering via rewind - sounds like the workspace isn’t properly loading the latest checkpoint state on startup.

A few things that would help us track down the exact cause:

  1. Is your project in a git repo? If so, after the bug happens (before you rewind), could you open a terminal and run git status? This tells us whether the files were actually modified on disk or whether the UI is just showing the wrong state.

  2. Screen recording of the close → reopen → code missing → rewind flow. Seeing exactly what the workspace looks like before and after rewind would help a lot. A quick recording of the issue manifesting and then the recovery would be ideal.

  3. Developer Console errors on startup. After reopening and noticing the missing code (before rewinding): open Help > Toggle Developer Tools, go to the Console tab, and screenshot any red error messages. These often reveal what failed during state restoration.

  4. Is this a single file or many files? When you say “half the code” is deleted — is that within one file (half the lines gone), or half the files in the project appear empty?

Your data is safe since checkpoints have it, but we want to understand why the workspace isn’t loading correctly on startup so we can fix it.

Hi, before sending the screen recording, could these screenshots show the root cause of the issue?

Running git status on terminal says could not open directory, permission denied. I tried connecting with git before but it didn’t proceed since it was in a stuck state, so I don’t know if it’s connected.

This only affects the file I’m working with, so just 1 file currently.

Those screenshots are helpful - the key error is in the second one: Failed to execute git. Combined with git status giving “permission denied,” git isn’t working at all on your machine. Cursor relies on git internally to manage code state, so this is very likely causing the issue.

The Session not found error also confirms the previous session didn’t shut down cleanly. The other warnings (TrustedScript, API proposals, “team member” errors) are unrelated noise.

Two things to check:

  1. Is git installed? Open CMD or PowerShell (not inside Cursor) and run git --version. If it’s not recognized, install Git for Windows - Cursor needs it on your PATH.

  2. Is the project in OneDrive or another cloud-synced folder? That’s the most common cause of “permission denied” on Windows. If so, move it to a local path like C:\Projects\.

A screen recording of the close → reopen → code missing → rewind flow would still help, but fixing git first may resolve things on its own.

I had the AI troubleshoot and this is what it said:

What they said Status
Is Git installed? Run git --version :white_check_mark: Yes — Git 2.53.0 works in PowerShell
Git in the project folder (not your whole user folder) :white_check_mark: Repo is in dropper game, bad C:\Users\monts\.git is gone
Git works in the project :white_check_mark: git status runs clean, no permission denied
git.path in Cursor :white_check_mark: Added to your Cursor settings
TrustedScript / team member / API warnings = noise :white_check_mark: Correct — we agreed to ignore those

:warning: Partially done

What they said Status
“Failed to execute git” = Git broken" :warning: Half true. Git works in PowerShell. Cursor still shows that line because it tries to read GitHub remote info for analytics — you have no GitHub link. That line can stay even when Git is fine.
“Cursor relies on Git to manage code state” :warning: Git is set up, but your file going to 0 lines is almost certainly Agent edits, not this Git error. Fixing Git didn’t stop the wipe.

Here is also the screen recording showcasing this bug

(Note: to avoid confusion, I am not using Windows 7, this is just a reskin applied to windows 11).

(Updated)

To my knowledge I don’t have any cloud-syncing on.

I was able to resolve my issue. I had some weird problem with the file I was working on, and renaming it to something else, and then renaming another copy to have the same file name fixed it.

I think what happened was Cursor reloading a broken/truncated version into the editor on every launch, because it had saved bad state tied to my specific file path. I think what may have caused it is the file slowly growing past Cursor’s ~500KB internal sync limit (max ~500KB in the logs), after which it kept failing to load the newest version and instead reused a stale/truncated snapshot. My other large files didn’t grow over time — they were copy-pasted already over the limit — so maybe they weren’t affected because they never went through that gradual crossing of the threshold the same way.

That’s just my guess though I don’t know for sure.