aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-22 12:32:14 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-22 12:32:14 -0400
commit57871e1b1f05ee2d87c07ed6e1bcb86d753f6a43 (patch)
tree3215d10cb2a039c85b18a9dd349efd7579248d75 /modules
parent6b82a6288fe1775f63894882ba9b1a9727780b45 (diff)
`textadept.editing.strip_trailing_spaces` should not apply to binary files.
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/editing.lua5
1 files changed, 3 insertions, 2 deletions
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