Applying code from the chat doesn't work

Over the past 2 days, whenever I try to apply code from the cursor chat it ends up deleting most of the code in the specific file.

Not sure what’s been happening.

This is a common problem, unfortunately. Several strategies to try to work around it:

  1. Ask chat to provide the updated code again but more clearly show the changes (then attempt to reapply)
  2. Close/reopen Cursor and reattempt
  3. Copy the updated code from chat and then in your code, highlight the function or section (or if not a huge file, the whole file sometimes works) and then Ctrl/Cmd-K to “Generate” Then in the generate window write: Update: and paste the updated code. Then you can review and decide whether to accept or reject the applied code changes
1 Like

Thanks! I’ll give some of these a try. Haven’t done #3 in that exact way.

1 Like

I also switched to o1-mini and that seemed to solve this too. I was experiencing the issue specifically with Claude sonnet 3.5

1 Like