Cursor modifying files on startup

Had to do this trick here for the problem to stop :

@deanrie Hi!
Any plan to fix this?
I had to uninstall the cursor+app data after 30 files were changed on startup. I was happy for a few days, but now it has started again

I’m also getting the same issue here on Windows.

Accepting changes makes 0 difference, but perhaps as some users have said it’s an old agent chat causing it.

Accepting the changes for GitHub should automatically accept the changes really.

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

On Cursor startup, the loadInlineDiffs function modifies 45+ files on disk by appending trailing newlines, even though files.insertFinalNewline is set to false in user settings. The files are written to disk during the restoration of cached AI code block diffs, causing unwanted git changes.
The renderer.log shows a listener leak (200+ listeners) during loadInlineDiffs which loads 197 cached diff entries. All affected files are modified at the exact same timestamp during startup.

Steps to Reproduce

  1. Use Cursor with AI features (chat/composer) over time, which accumulates codeBlockDiff entries in the global state database
  2. Have “files.insertFinalNewline”: false in user settings
  3. Restart Cursor / reload window
  4. Check git diff --stat - multiple files now have | 1 + (single line addition)
  5. The added line is always a trailing newline at end of file

Evidence:
All 45 files modified at identical timestamp 2025-12-16 17:02:30
Renderer.log shows loadInlineDiffs running at 17:02:28.528 with listener leak
Global state database contains 25,852 codeBlockDiff entries in cursorDiskKV table

User settings explicitly have “files.insertFinalNewline”: false

Expected Behavior

The loadInlineDiffs function should:
NOT write files to disk - it should only restore diff state in memory for display
Respect the files.insertFinalNewline: false setting if files must be touched
Not cause a listener leak when loading cached diffs

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.2.23
VSCode Version: 1.105.1
Commit: b3c95a7981bb3057526f1f865e8c307a9911ce00
Date: 2025-12-15T03:10:57.241Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.1.0

Additional Information

I have renderer log files showing the issue that I can send as well.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When quitting Cursor, a trailing newline is automatically added to files that don’t have one, even with files.insertFinalNewline set to false in workspace settings. This causes git status to show these files as modified every time I reopen the editor.

Steps to Reproduce

Steps to Reproduce:
Create or have a file that doesn’t end with a newline character
Commit it to git
Add “files.insertFinalNewline”: false to .vscode/settings.json or .cursor/settings.json
Open the project in Cursor
Quit Cursor (Cmd+Q / Alt+F4)
Reopen Cursor and run git status
The file now shows as modified with a newline added at the end

Expected Behavior

Expected Behavior:
Files without a trailing newline should remain unchanged when quitting Cursor, respecting the files.insertFinalNewline: false setting.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.2.20 (Universal)
VSCode Version: 1.105.1

Does this stop you from using Cursor

No - Cursor works, but with this issue

2 Likes

This keeps happening to me also. Still happening on latest cursor update. Version info below.

Version: 2.2.36 (Universal)
VSCode Version: 1.105.1
Commit: 55c9bc11e99cedd1fb93fbb7996abf779c583150
Date: 2025-12-18T06:25:21.733Z (10 hrs ago)
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.1.0

I do NOT agree this is a bug.
Prior version of Cursor incorrectly omitted end-of-file newlines, which has negative effects in all kinds of unexpected places.
These need to be fixed for your own safety sometime, may as well be next time you open cursor, right?

Still an issue in Version: 2.2.43

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I’m encountering an issue where Cursor adds blank lines to files without any intentional edits. This most often occurs when a workspace is left open overnight and then resumed the next day, or immediately after restarting Cursor.

These changes appear in Git as diffs showing added empty lines, even though I did not open or modify those files manually.

Notes / Observations

  • Affected files are not always actively opened or edited
  • Blank lines appear to be inserted silently
  • This can happen immediately on resume/startup, before any manual edits
  • Behavior is intermittent but recurring
  • Git clearly shows line additions consisting only of empty lines

Steps to Reproduce

  1. Open a workspace in Cursor
  2. Leave Cursor running idle overnight (MacBook asleep or lid closed)
  3. Resume Cursor the next day
  4. Observe Git diffs showing added blank lines in one or more files

Expected Behavior

Expected Behavior
Files should remain unchanged unless explicitly edited.

Actual Behavior
Cursor modifies files by inserting blank lines, resulting in unintended Git diffs.

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Cursor Version: 2.2.43 (Universal)
VS Code Version: 1.105.1
Commit: 32cfbe848b35d9eb320980195985450f244b3030
Build Date: 2025-12-19
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0

Additional Information

System

  • OS: macOS 15.6.1 (24G90), Darwin arm64 24.6.0
  • Hardware: MacBook Pro (Nov 2024)
  • Chip: Apple M4 Max
  • Memory: 36 GB

Impact
This introduces noise into Git diffs, increases the risk of accidental commits, and reduces confidence that files remain unchanged unless explicitly edited.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Are you sure this is really happening at all?

VSCode has a bug that it does not add the final \n or \r\n to new files.
If cursor is fixing this when it find that - then this is NOT a bug - it’s the opposite - it’s fixing the vscode bug from prior.

Can you show some “hexdump” of before and after to confirm to everyone (yourself included) what is actually going on?

I checked with hexdump -C.
Before, the file ended with ... 0a 7d 0a 0a (two trailing LF newlines after the final }).
After reopening, it ends with ... 0a 7d 0a 0a 0a (three trailing LF newlines).
So Cursor is inserting an additional trailing newline (extra blank line), not fixing a missing EOF newline.

Before:
00000180 2f 68 74 6d 6c 3e 0a 20 20 29 3b 0a 7d 0a 0a |/html>. );.}..|
0000018f

After:
00000180 2f 68 74 6d 6c 3e 0a 20 20 29 3b 0a 7d 0a 0a 0a |/html>. );.}…|
00000190

I can hard reset, close the workspace, open the workspace and the new lines are there. Does this for any workspace I open now.

@c_estep_tcbguy please accept my apologies (and festive best wishes!!) - yes, you’re totally right!

Since this would cripple so many people, yet so few seem to notice, my guess now is that this is a mac-only problem, and might be related to extensions you’ve got loaded?

You’re in an incredibly unique position - being able to reproduce this problem! Please try this - close cursor then run:-

cursor --disable-extensions

and see if that fixes things - if yes - you can manually “turn off half”, restart, etc, to narrow down the culprit.

Good luck!!

OK so go to each file and then accept changes generated by cursor, save the file then discard the changes of the file worked for me. The only annoying thing is I had to do that for each file. Then I just reset window and it comes back normal

Hey all - confirming we’re seeing a very similar issue on Windows 11, but in our case it’s NOT only trailing newlines / whitespace.

Environment

  • OS: Windows 11
  • Cursor: 2.3.7
  • Scope: reproducible for multiple team members
  • Extensions: cursor --disable-extensions does not help

What happens

  • Repo is clean when we close Cursor.
  • After restarting Cursor, Source Control shows some files as modified again, including files we previously discarded.
  • The diffs are real code changes (normal lines), not whitespace/CRLF/newline noise.
  • The changes appear to be old Agent edits resurfacing (from earlier Agent sessions).
  • It only seems to affect files that were touched by the Agent (we mostly use Agent mode).

Minimal repro

  1. Run an Agent that edits file(s)
  2. Do not click “Keep Files” / “Keep” in the inline diff UI for those Agent edits
  3. Commit/pushand close Cursor
  4. Reopen / restart Cursor
  5. Those Agent-touched files show as modified again (old Agent edits reappear)

Workaround that “unsticks” it (but annoying)

For each affected file:

  1. Open the file and explicitly click the inline diff banner “Keep” (Keep/Undo UI)
  2. Save
  3. Discard changes in Source Control / git restore

After doing this per file, restarting Cursor no longer makes those same files reappear as modified.

Hypothesis

This looks like stale cached inline diffs / review state from old Agent sessions being restored on startup and re-applied to disk, even after the Git working tree was reverted. So Git discard alone isn’t durable until the inline diff state is resolved via Keep/Undo.

This affects many pepole and creates a lot of noise/uncertainty around whether the working tree is truly clean.

Same here (and very anoying when it’s happening on 300 files…) :
Version: 2.2.44 (user setup)
VSCode Version: 1.105.1
Commit: 20adc1003928b0f1b99305dbaf845656ff81f5d0
Date: 2025-12-24T21:41:47.598Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200

I hope we will have a fix pretty soon. Thank you for your help.

Same issue, it multipliesquickly, when you have multiple repos in a workspace

Still not fixed. After opening cursor, changes that were made in previous commits just rolled back in code. It breaks app again and again, so before closing cursor i should always commit, overwise I’m loosing code changes when reseting to the last commit. very anoying, and it’s been months. :-1: