From c355e75eca598d5cf2d9c8529d3061e35707b948 Mon Sep 17 00:00:00 2001 From: Ben Truyman Date: Mon, 30 Apr 2012 21:38:29 -0500 Subject: [PATCH] Added support for in/excluding empty lines from being matched as trailing whitespace --- trailing_spaces.py | 4 +++- trailing_spaces.sublime-settings | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/trailing_spaces.py b/trailing_spaces.py index 003c2de..41ee2fc 100644 --- a/trailing_spaces.py +++ b/trailing_spaces.py @@ -32,7 +32,9 @@ trailing_spaces_enabled = bool(ts_settings.get('trailing_spaces_enabled', # Return an array of regions matching trailing spaces. def find_trailing_spaces(view): - return view.find_all('[ \t]+$') + include_empty_lines = bool(ts_settings.get('trailing_spaces_include_empty_lines', + DEFAULT_IS_ENABLED)) + return view.find_all('[ \t]+$' if include_empty_lines else '(?<=\S)[\t ]+$') # Highlight trailing spaces diff --git a/trailing_spaces.sublime-settings b/trailing_spaces.sublime-settings index 1db0b4e..ece3eda 100644 --- a/trailing_spaces.sublime-settings +++ b/trailing_spaces.sublime-settings @@ -1,10 +1,13 @@ { // Color is determined by scope - "trailing_spaces_highlight_color" : "invalid", + "trailing_spaces_highlight_color" : "invalid", // Max file size to search - "trailing_spaces_file_max_size" : 1048576, + "trailing_spaces_file_max_size" : 1048576, // By default plugin is enabled or disabled (true|false) - "trailing_spaces_enabled" : true + "trailing_spaces_enabled" : true, + + // By default empty lines are cleared + "trailing_spaces_include_empty_lines" : true }