React imports are getting corrupted every time I create or update a .tsx file

Description

First, this bug is nearly stopping me from using Cursor because it’s basically making every change to a React file a nightmare.

Whenever Cursor creates a new React .tsx file or modifies the imports, they always get corrupted in insane ways:

But they are getting corrupted when implemented somehow, and so they trigger linter errors, which Cursor then endlessly tries to fix if I don’t stop it, ask it to give me the correct imports, and then copy paste them manually (or use the initially suggested diff).

Two other notes:

  • If I paste the correct changes into the file after opening it fresh and then hit save, the changes I just made are reverted to the corrupt version of the imports.
  • If i copy the imports into a file in the diff state, into the “add” portion of the diff and hit “accept”, the imports revert to the corrupted format

Workaround

The only way to workaround the issue is to accept the corrupt diff, then copy the correct imports from the chat window, paste them in, let autosave save it, then close the file.

In my opinion this is a pretty bad bug. Cursor is generating essentially random code in the imports section of the file. It often hallucinates imports that aren’t even relevant to my project, like Material UI, for example.

There are other instances of things like repeated characters and punctuation in the middle of symbols or at the end of a statement, like:

import React from 'react';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Cursor version: 0.48.9 (Universal)
OS: macOS 14.1.1 (23B81)

1 Like

Yes its insane.

I spend more time on fixing the crazy imports than on the actual code.

I love cursor, but this is just soooooo annoying that i sometimes consider switching.