Cleanup unused imports creates infinite loop

Describe the Bug

Agent breaks and runs in an infinite loop when cleanup unused imports is on

Steps to Reproduce

When the agent tries to save the file after adding an import, if the auto remove unused imports setting is turned on, the import gets removed and the agent tries to add the import again in a loop.

Expected Behavior

Either it should add the code that uses the import at the same time as it adds the import, or it should not save the file in between adding the import and adding the code, or it should temporarily disable the remove unused imports setting.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.0.0
VSCode Version: 1.96.2
Commit: 53b99ce608cba35127ae3a050c1738a959750860
Date: 2025-06-04T19:21:22.523Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.5.0