Gemini CLI Fix: Detect Mixed Line Endings to Prevent Full File Rewrites

shoemoney · ghdev · 2026-08-24

This PR fixes a bug in the detectLineEnding function in Google's Gemini CLI. The previous logic classified a file as CRLF if it contained even a single \r\n sequence, causing files with mixed line endings (mostly LF) to be fully rewritten to CRLF on minor edits. The fix implements a purity-based check, returning CRLF only if all newlines match that style, preventing destructive, unintended diffs.

Original post →

More from coding & agent

coding & agent channel →