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;