diff --git a/highlight_whitespaces.py b/highlight_whitespaces.py index d0a23d2..4470fdc 100644 --- a/highlight_whitespaces.py +++ b/highlight_whitespaces.py @@ -27,6 +27,7 @@ import sublime_plugin DEFAULT_MAX_FILE_SIZE = 1048576 DEFAULT_COLOR_SCOPE_NAME = "invalid" DEFAULT_IS_ENABLED = True +DEFAULT_LAST_WHITESPACE = False #Set whether the plugin is on or off hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings') @@ -39,7 +40,12 @@ def is_find_results(view): # Return an array of regions matching whitespaces. def find_whitespaces_spaces(view): - return view.find_all(' {2,}') + last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE)) + regex = ' {2,}' + if last_whitespace: + regex += '| {1,}$' + + return view.find_all(regex) def find_whitespaces_tabs(view): return view.find_all('\t+') diff --git a/highlight_whitespaces.sublime-settings b/highlight_whitespaces.sublime-settings index 41e824a..c4c4e93 100644 --- a/highlight_whitespaces.sublime-settings +++ b/highlight_whitespaces.sublime-settings @@ -9,5 +9,8 @@ "highlight_whitespaces_file_max_size": 1048576, // By default plugin is enabled or disabled (true|false) - "highlight_whitespaces_enabled": true + "highlight_whitespaces_enabled": true, + + // Allow the highlighting of the last whitespace, one or more time + "highlight_last_whitespace": true }