diff --git a/highlight_whitespaces.py b/highlight_whitespaces.py index e7ee916..27603f4 100644 --- a/highlight_whitespaces.py +++ b/highlight_whitespaces.py @@ -31,6 +31,7 @@ DEFAULT_COLOR_SCOPE_NAME = "invalid" DEFAULT_IS_ENABLED = True DEFAULT_CHECK_SPACES = True DEFAULT_CHECK_TABS = True +DEFAULT_LAST_WHITESPACE = False #Set whether the plugin is on or off hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings') @@ -43,7 +44,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 e35ffb5..f8d2ad1 100644 --- a/highlight_whitespaces.sublime-settings +++ b/highlight_whitespaces.sublime-settings @@ -15,5 +15,8 @@ "highlight_whitespaces_check_spaces": true, // Whether to check for tabs - "highlight_whitespaces_check_tabs": true + "highlight_whitespaces_check_tabs": true, + +// Allow the highlighting of the last whitespace, one or more time + "highlight_last_whitespace": true }