How to Keep AI from Removing Vital Commented Code During Development?

I’ve been using Cursor to assist with my coding, and overall, it does a pretty good job. However, I’m facing a recurring issue that’s really impacting my workflow. Each time I ask the cursor to make changes to my code, it tends to erase any commented lines, which I rely on heavily for testing and debugging.

Despite specifying in my prompt to not touch the comments, it still removes them. This often results in me losing important pieces of code that I’ve set aside for later use, which is a massive hit to productivity. I end up spending more time backing up these comments in separate files than actually benefiting from the cursors help.

I’m curious—am I alone in this? Is there a better way to maintain commented code for future reference while using cursor? Personally, I find it difficult to program effectively without keeping commented lines for later, but this issue is slowing me down. Any advice on how to tackle this would be greatly appreciated.

1 Like

Hi @figarocaninis

If you need to control your actions, use the chat instead of Composer.

1 Like

Hello, @deanrie thanks for replying…

I never used Composer. Everything I mentioned was related to Chat (CTRL+L). Forgot to mention it, sorry about that.

Regards

I wonder if a bigger context window will be a solution to the issue you are facing. Could be nice to have a feature where you can highlight text and lock the text/code so it can’t be edited by Composer or ‘Apply from Chat’, but use the locked text as context, and if a change is required for the locked code, write the code below that code but will comments.

1 Like

ive encountered this daily. it’s annoying as well

i think i’ve noticed it more when the context window has been reduced after a long chat/composer

i think it hallucinates a lot more so i try to stay away from long chats to reduce it even after have it in my cursorrules

if anyone has a better suggestion please share

1 Like