Disallow cursor to delete files automatically

Can I somehow disallow cursor to delete files automatically? It happens regularly, perhaps 2-3 times per day, that cursor deletes one of my modules. I don’t think it should do that without my confirmation. This happened somewhere after one of the latest updates.

I would love to disallow file access in the settings, for example, but I didn’t find that option.

3 Likes

Hi @ekevu456. Can you share a bit more about how/when a file is deleting? Is it when you apply suggested changes from a chat/composer for example? Do you see that the AI is proposing a file deletion?

I haven’t confirmed the pattern yet, that’s why I can’t really avoid it. I believe it happens in some instances when I reject proposed changes from AI. However, I want to reject only that specific change which happens a while after the file has been created, but not the whole file. I don’t see a warning.

This might only happen if the file was created recently, maybe even in the same thread, but I can’t be sure.

I know that AI can also create files, but right now, I would be happier to avoid the loss and oversee the process, which means I would want to disallow AI to handle files and do this manually myself.

Most likely, this happens when creating files in Composer, and you’re rejecting the changes, which deletes the files. You need to pay close attention to the process to avoid this.

I wasn’t deliberately using it, I only used the AI chat. However, I deactivated the feature for now, maybe it interferred.

Still, the following behaviour is okay: AI creates a module, and gives me the opportunity to accept or reject. If I reject, I reject the file creation, so it deletes it again.

But while I am already making subsequent changes to the same file, it should only reject the change proposed, but not the whole file by itself.

1 Like

If it created it, it can delete it unless you explicitly tell it not to, though it might still do it later. To prevent this, start a new session so it won’t know it created the previous files, but it can still write new code in them. Cursor isn’t automatic coding, you need to watch each step and accept/reject AI suggestions. That’s how it works for now

I understand that, but I don’t understand why you defend that behaviour. AI suggests a change. I don’t want that change, so I click reject. This means that I want to get the state without the proposed change, but in no ways it is intuitive that this deletes the file like an insulted child saying “if you don’t like my suggestion, then you can do the whole thing yourself”.

Instead, if the system attempts to delete a file, there should be a proper warning before that happens.

Yeah, you’re right, there should be a warning.

In the same case, if you click “reject” after “apply,” the entire file will be deleted without any hint. Thanks to the git system; otherwise, my thousands of lines of code would become void.

I have the same issue and it’s REALLY annoying. It happens when I undo changes to a file (CMD+Z) and click reject changes, it just straight up deletes the file. It doesn’t even need to be a new file or created by composer.

Please fix this.

+1, made an account just to echo this. Cursor keeps deleting entire files when a change is rejected. Incredibly frustrating, especially as a Pro user… paying to see my own hard work deleted and with no recovery option (working locally off of Git). Deleted files don’t even go to trash, they’re just gone. At first I thought file deletions were limited to only those Cursor creates as part of a net new file edit, so I no longer allow it to create files. But it also appears to delete files I had made myself. What is going on?

This problem has happened to me many times and needs to be fixed.

I agree, this problem made me have to re-write several files already. In my opinion it should just reject the last change and keep everything else. If you really want to delete the file, you’ll do that yourself at that point.

+1 for having the same problem (reject proposed application or cmd z on file created by composer). It’s really annoying, because it happens so easily…

I used this workaround to restore the files:

  • In the chat, click on the filename. it will regenerate the file in most cases but the filename will show as deleted (red/strike-through)
  • simply save the file again

Same issue - this happens constantly. Sometimes if I’m just undoing some changes, the whole file is deleted. Extremely frustrating.

This is turning into a deal breaking problem that gets me every day. Typically it’s 1 or 2 files and I’ve learned to make commits as checkpoints because of it. But just now it nuked every single new file in my project. I asked it to do a project restructure, which it did well enough. I had been refactoring for about an hour, and then had it suggest some code changes which I rejected, and then all my work vanished. Not just the change, not just the file I was in, but every single file that I had previously accepted changes for during the restructure. Now I have to redo all this work while feeling completely defeated. The sensible part of me says to stop using Cursor until this problem is fixed

yo team ! this needs to be fixed! major problem with major repercussions !

1 Like

This is a big problem, cursor is deleting files even when it doesn’t create them. I just deleted a whole uncommited file by rejecting changes cursor made. It did not create the file or anything.

I was able to replicate this issue.

  1. close the file that cursor is suggesting changes for.
  2. Click apply on the changes so the file opens up and shows the changes.
  3. Reject the changes

The file will then be completely deleted, instead of just the changes being rejected.

Version: 0.42.4
VSCode Version: 1.93.1
Commit: b1e87884330fc271d5eb589e368c35f14e76dec0
Date: 2024-10-29T17:17:29.347Z (1 wk ago)
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 24.1.0

Im running into same problem, and these days apply is very slow, and it makes this bug even more easier to happen