Apply code update from chat creates a new file

What this person is reporting sounds similar:

Exact same issue. Using Claude-3-5-sonnet 20241022 and regular Claude

It is the most annoying thing in the world tbh and makes Cursor completely unusable.

Composer/Chat suggests a change for a file, instead of making the edit to that file, it creates the file 1 directory above.

Dev halp

4 Likes

Same here on macOS. What helps is if I specifically mention with @ the component or file ai want to modify. But sometimes this is hard to know, all of the files that need updating and I dont want to limit Cursor with that.

For simple Python scripts it worked normally. I encountered this while working on VueJS project.

1 Like

Same issue. Iā€™m not an engineer so I rely on Cursor to know when to edit vs create new. I frequently end up with duplicate file/folder branches in wrong locations in my file system when using the ā€œApplyā€ button. Love the software, looking forward to a fix. Thanks.

Version: 0.42.3
VSCode Version: 1.93.1
Commit: 949de58bd3d85d530972cac2dffc4feb9eee1e40
Date: 2024-10-16T17:56:07.754Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

1 Like

Same for me.

Exasperating.

I switched to an openAI model and seems to be better now but I always ask what file should be edited when it is not obvious to Cursor and copy/paste the suggestion. Back on track with this workaround.

This is still bugging me

I can reconfirm that the same is happening for meā€¦makes it impossible/almost useless to use. It happened after Cursor recommended that I pull css/js files into css/js folders for better organization. From that point on, I canā€™t get Cursor to reference the correct file.

Sometimes I will explain how irritated I am at it and provide it the relative path of the correct file and it then applies the change correctly (indicating a model issue), but that does not consistently work.

same here, apply stopped working suddenly. when I ask cursor to review part of the code and then click apply he is creating new folder structure and creates new file with only the code which in most case is just a partial code. Please fix it

Same issue here, super frustrating.

1 Like

This is still broken and honestly makes the app completely unusable.

I have created custom prompts to tell the model to use the correct files, @'ed the correct files, used CTRL+ ENTER to use full codebase files, and even attached screenshots of the directory.

SOMETIMES this will fix it but other times NOTHING will fix it and it will ALWAYS create a new SRC/XXX FILE

Please fix this devs. It makes the app useless.

1 Like

Set up a new account so I can add the reply here that I too have the issue. Itā€™s quite annoying.

1 Like

Same here on MacOS

1 Like

Same here, using latest version and Ubuntu 22.04. I asked the sonnet 3.5 why is it creating new files instead of editing file that user provides. He explains why, i wonā€™t go into detail, because it is extremly hard to copy paste from Cursor, because everything is in sections and there is no way to mark the whole content properly. However after chatting with it, explaining him it is creating new files on different path instead of editing, he realized the mistake. I asked him to write a RULE that will prevent further instances from doing that, here is the rule:

VERY, VERY IMPORTANT RULE: Path Handling Rule: When showing code edits, you must use EXACTLY the same file path as shown in the userā€™s ā€œCurrent Fileā€ section - no modifications allowed. Donā€™t add or remove any slashes, donā€™t change the path structure, and donā€™t use paths mentioned within the fileā€™s content. The path must be an exact character-for-character match to what appears after ā€œCurrent File:ā€. This is critical because:

  • Adding/removing leading slashes will break the edit functionality
  • Changing the path structure will cause the IDE to create new files instead of editing existing ones
  • The only correct path is the one shown in ā€œCurrent File:ā€ section

Example:
If Current File shows:
folder1/folder2/file.txt
Then use:
language:folder1/folder2/file.txt
NOT:
language:/folder1/folder2/file.txt or language:file.txt

It seems like it helped. But i am not sure if this is the right way of fixing things. Aurhors of cursor, must fix this in a better way.

1 Like

Just tried this rule and it worked for me.

Like you say, not an ideal solution, but at least it helps for now whilst we wait for the Cursor team to sort it out.

Nice one @teneon

1 Like

@robwheatley No problem! :slight_smile:
I was testing this rule just for Chat (CTRL + L), i did not test it for composer. I am not sure if this rule would somehow negatively interfere with Composer, since there are multiple files opened etc. If someone knows this or can test, let us know please!