Starting yesterday, Cursor frequently inserts indentation errors in my python code, then notices them and tries to fix them, says it fixed them, but has done nothing. This happens with several different models. I pointed this out to the model at one point and it tested and agreed that “everything seems completely broken” and proceeded with copying the entire code to a new file, fix the errors and replace the old file with the new. This worked.
Steps to Reproduce
Have it write python, ask for it to correct linter errors
Operating System
Windows 10/11
Current Cursor Version (Menu → About Cursor → Copy)
As an addition I can add that I can see it working on the file, removing the linter errors, but then after it fixes the last one, the all are added back.
Chaning model does not matter, creating a new chat does not matter. BUT, if I close Cursor and open it again, same project, ask it to fix the errors, it suddenly works.
Indentation errors occur constantly with every language I program in, it removes a full indentation level when inserting a code snippet, I noticed this seems to happen primarily when the agent reads a portion of the file rather than the entire file. If this portion has a common indentation the agent will start causing these indentation errors.
Thanks for the report. Can you please check if you’re still facing this issue on the latest version?
You can get the latest version from Download · Cursor
Actually, I JUST ran into something similar today, but this time, Composer1 could solve it eventually. I believe the original problem is the same (that it somehow can’t correctly fix the indentation errors for some reason, maybe due to not looking at enough code as someone above said), but Composer1 tried harder than just using the same method to incorrectly “fix” the indentation.
It repeatedly found the linter error (after I pointed it out), and tried several times tried to fix it by just editing the code normally: Fixing the indentation issue:
After 4-5 tries of that it tried several things: Reading a larger section to understand the exact formatting: Checking for mixed tabs/spaces: Trying a different approach with exact whitespace matching: Verifying the file was updated and checking for caching issues: Replacing the entire function to fix the indentation:
Neither of these worked either, the indentation error remained. Then it did this: Fixing the indentation directly with a Python script:
Which actually fixed the issue. Props for not giving up and eventually fixing it, but it would have an easier time if it didn’t have to resort to writing a python script for this.