From 57871e1b1f05ee2d87c07ed6e1bcb86d753f6a43 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Thu, 22 Oct 2020 12:32:14 -0400 Subject: `textadept.editing.strip_trailing_spaces` should not apply to binary files. --- modules/textadept/editing.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/textadept/editing.lua') diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 0c35942e..e130125c 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -9,7 +9,8 @@ local M = {} -- Match the previous line's indentation level after inserting a new line. -- The default value is `true`. -- @field strip_trailing_spaces (bool) --- Strip trailing whitespace before saving files. +-- Strip trailing whitespace before saving files. (Does not apply to binary +-- files.) -- The default value is `false`. -- @field autocomplete_all_words (bool) -- Autocomplete the current word using words from all open buffers. @@ -269,7 +270,7 @@ end -- Prepares the buffer for saving to a file by stripping trailing whitespace, -- ensuring a final newline, and normalizing line endings. events.connect(events.FILE_BEFORE_SAVE, function() - if not M.strip_trailing_spaces then return end + if not M.strip_trailing_spaces or not buffer.encoding then return end buffer:begin_undo_action() -- Strip trailing whitespace. for line = 1, buffer.line_count do -- cgit v1.2.3