From 3ff994d251e440ca1cb0685196faeade606a6118 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Tue, 6 Oct 2020 00:04:53 -0400 Subject: Only change EOL mode if an EOL is actually detected. --- core/file_io.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/file_io.lua') diff --git a/core/file_io.lua b/core/file_io.lua index 46cee08f..04ad9680 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -136,7 +136,8 @@ function io.open_file(filenames, encodings) ::encoding_detected:: buffer.code_page = buffer.encoding and buffer.CP_UTF8 or 0 -- Detect EOL mode. - buffer.eol_mode = text:find('\r\n') and buffer.EOL_CRLF or buffer.EOL_LF + local s, e = text:find('\r?\n') + if s then buffer.eol_mode = buffer[s < e and 'EOL_CRLF' or 'EOL_LF'] end -- Insert buffer text and set properties. buffer:append_text(text) buffer:empty_undo_buffer() -- cgit v1.2.3