last whitespace property enabled

This commit is contained in:
Ezequiel Bergamaschi 2013-08-20 22:05:50 -03:00
parent 04b88f15bd
commit 17ca7f2616
2 changed files with 11 additions and 2 deletions

View File

@ -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+')

View File

@ -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
}