Discarding changes in Git then asking the AI to edit the file can leave the AI unaware that the previous changes were removed.
Let the AI know you discarded changes before asking it to edit again.
Especially gets tricky when you repeat the same process multiple times in the same chat, so it may be worthwhile to try on a new chat.
A formatting extension could be reformatting the whole file after the AI makes a change. So that’s worth checking - is it applying its rules to the entire document?
I think this is the main problem.
Try disabling extensions temporarily with cursor --disable-extensions, and turn off “Format on Save” in VS Code settings (from Cursor > Settings > VS Code settings menu) as well.
Verify whether only the intended part changes after this. Hopefully this helps narrow down the problem.
To me, it sounds like this file may not have been formatted correctly by your project’s formatting logic in the first place, which is likely causing this fix? Try comparing how formatting without any extensions goes, or with another editor to compare.
That’s all I have; other experienced Cursor users or staff may have additional insights.
It looks like the model only edits one line (changes msg to messages). So is it really changing the whole file? I am doubtful its messing up the file syntax or making a bunch of edits behind the scene. If it was confused of the state of the file, it would unnecessarily make additional changes, not make those changes invisibly.
Something worth trying: if you discard the changes (like in your video), then make the fix manually yourself (the same change the model did), then sync the changes, do you get the same result? That might narrow it down between if its the model or something with your file or git. May be worth discarding the changes and rebooting Cursor if the issue persists.