apply_patch inserts LF into CRLF files on Windows, causing VS line-ending warnings and unreliable undo

Open 💬 1 comment Opened May 29, 2026 by xjx22

What version of the Codex App are you using (From “About Codex” dialog)?

26.521.10419

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows 11 25H2 26200.6899

What issue are you seeing?

On Windows, when Codex edits an existing CRLF code file, apply_patch appears to insert or replace lines using LF-only line endings. This creates mixed line endings in the same file.

Visual Studio then shows an “Inconsistent Line Endings” warning.

If the assistant subsequently normalizes the file back to CRLF, the Codex app’s built-in undo/revert feature can fail. The revert dialog says some files could not be restored / were skipped.

This makes Codex edits difficult to undo reliably in Windows/Visual Studio projects.

What steps can reproduce the bug?

Feedback ID: 019e7251-6bbb-7340-9ac7-801c6d1c5880
Feedback ID / session id:
019e7251-6bbb-7340-9ac7-801c6d1c5880

Reproduction steps:

  1. Use Codex App on Windows with a repository containing CRLF code files.
  2. Open a Visual Studio project file, for example a .vb file.
  3. Ask Codex to make a small edit using apply_patch, such as adding a test comment.
  4. Open or save the edited file in Visual Studio.
  5. Visual Studio reports inconsistent line endings.
  6. Inspect the file line endings. The file contains mixed CRLF and LF lines.
  7. Ask Codex to normalize the file back to CRLF, or manually normalize it.
  8. Try using the Codex app “undo/revert changes” button.
  9. The revert may fail and report that some files were skipped / could not be restored.

Observed Git config / file state:

  • git config core.autocrlf = true
  • Example file initially shows as CRLF in working tree:

i/lf w/crlf attr/text=auto

  • After apply_patch edits, inserted lines can become LF-only, causing mixed line endings.

What is the expected behavior?

apply_patch should preserve the existing line ending style of the edited file.

If a file uses CRLF, inserted or replaced lines should also use CRLF. This would avoid Visual Studio line-ending warnings and should keep Codex app undo/revert reliable.

Additional information

This likely affects Windows projects broadly, not only VB.NET.

The issue was observed in a Visual Studio / VB.NET project, but the root problem appears to be line-ending preservation during apply_patch writes.

The project path also contains non-ASCII / Chinese directory names, but the strongest evidence points to LF-only lines being inserted into existing CRLF files.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗