Absurd amount of indentation errors (python)

Describe the Bug

The code editing tools consistently introduce indentation errors that persist even after manual correction and git reverts. These errors appear as Python IndentationError exceptions that prevent module imports and code execution. The errors seem to accumulate over multiple edit operations and become increasingly difficult to resolve.

Steps to Reproduce

  1. Start with a working Python file, 500 lines or longer.
  2. Use the search_replace tool to make multiple edits to the file
  3. Attempt to import or execute the modified Python code
  4. Observe IndentationError exceptions like:
    IndentationError: unindent does not match any outer indentation level
  5. Critical: Even after manually fixing indentation errors or reverting to a prior git state, the errors persist
  6. The errors seem to compound - each subsequent edit operation introduces new indentation issues

Observed Symptoms:

  1. Immediate Errors: Import failures with IndentationError after edit operations
  2. Persistent State: Errors continue even after:
  • Manual indentation fixes
  • Git reverts to previous working commits
  • Multiple correction attempts
  1. Cascading Failures: Initial indentation errors seem to create additional issues in subsequent edits
  2. Unpredictable Locations: Errors appear in various parts of the file, not just at edit sites

Impact:

  • High: Prevents code execution and testing
  • Blocks Development: Unable to verify fixes or run integration tests
  • Accumulating Technical Debt: Each edit session makes the problem worse
  • Workflow Disruption: Requires manual intervention to restore working state

Potential Root Causes:

  • Mixed Whitespace: Edit tool may be mixing tabs and spaces
  • Context Awareness: Tool may not be preserving surrounding indentation context
  • Multi-line Edit Issues: Complex replacements may misalign indentation blocks
  • State Persistence: Tool may be maintaining incorrect indentation state between operations

Workaround:

  • Currently requiring manual correction of indentation after each edit operation, but even this is unreliable as errors seem to persist or reappear.

Expected Behavior

Files don’t manifest random indentation errors in places where they haven’t even been edited. Fresh indentation errors do not appear when reverting code to previously good state.

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.3.8 (user setup)
VSCode Version: 1.99.3
Commit: a1fa6fc7d2c2f520293aad84aaa38d091dee6fe0
Date: 2025-07-31T21:46:17.109Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100

Additional Information

The problem comes in waves. Sometimes it doesn’t happen for many hours. Sometimes it happens with every single change.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

hi @tiz.io and thank you for the bug report.

Which model are you using?

Could you post a Request ID with privacy disabled so we can look into the details? Cursor – Getting a Request ID

1 Like

You bet. I’ll generate one with a project I can share.
Using claude-4-sonnet.

1 Like

I’ve been trying to repro this, but it hasn’t manifested more than in very minor cases in the past week or so. It may have been fixed. I’ll update if it happens at large scale again.

1 Like

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.