From 5cbd60d06ce4788e8c937c923baa023a1e428a85 Mon Sep 17 00:00:00 2001 From: UnnaturalTwilight <107954129+UnnaturalTwilight@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:24:36 -0500 Subject: [PATCH] use platform default line ending when opening a single line file rather than assuming CRLF --- crates/edit/src/buffer/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/edit/src/buffer/mod.rs b/crates/edit/src/buffer/mod.rs index 9ea448542f6..5f4ca052f24 100644 --- a/crates/edit/src/buffer/mod.rs +++ b/crates/edit/src/buffer/mod.rs @@ -769,8 +769,8 @@ impl TextBuffer { } } - // We'll assume CRLF if more than half of the lines end in CRLF. - let newlines_are_crlf = crlf_count >= lines / 2; + // We'll assume CRLF if more than half of the lines end in CRLF. If there is only a single line, we'll use the platform default. + let newlines_are_crlf = if lines == 0 { cfg!(windows) } else { crlf_count > lines / 2 }; // We'll assume tabs if there are more lines starting with tabs than with spaces. let indent_with_tabs = tab_indentations > space_indentations;