aboutsummaryrefslogtreecommitdiff
path: root/core/file_io.lua
diff options
context:
space:
mode:
authormitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-06 00:04:53 -0400
committermitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-06 00:04:53 -0400
commit3ff994d251e440ca1cb0685196faeade606a6118 (patch)
tree098800cbae0aeb2cec1421ef2e78bae3981e8b19 /core/file_io.lua
parent4e9d8f853923f87182dc89849bba34b23cf3bd2d (diff)
downloadtextadept-3ff994d251e440ca1cb0685196faeade606a6118.tar.gz
textadept-3ff994d251e440ca1cb0685196faeade606a6118.zip
Only change EOL mode if an EOL is actually detected.
Diffstat (limited to 'core/file_io.lua')
-rw-r--r--core/file_io.lua3
1 files changed, 2 insertions, 1 deletions
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()