diff --git a/highlight_whitespaces.py b/highlight_whitespaces.py index d0a23d2..e7ee916 100644 --- a/highlight_whitespaces.py +++ b/highlight_whitespaces.py @@ -11,7 +11,9 @@ Config summary (see README.md for details): "highlight_whitespaces_space_highlight_scope_name": "invalid", "highlight_whitespaces_tab_highlight_scope_name": "invalid", "highlight_whitespaces_file_max_size": 1048576, - "highlight_whitespaces_enabled": true + "highlight_whitespaces_enabled": true, + "highlight_whitespaces_check_spaces": true, + "highlight_whitespaces_check_tabs": true } Forked from https://github.com/SublimeText/TrailingSpaces/ by Jean-Denis Vauguet , Oktay Acikalin @@ -27,6 +29,8 @@ import sublime_plugin DEFAULT_MAX_FILE_SIZE = 1048576 DEFAULT_COLOR_SCOPE_NAME = "invalid" DEFAULT_IS_ENABLED = True +DEFAULT_CHECK_SPACES = True +DEFAULT_CHECK_TABS = True #Set whether the plugin is on or off hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings') @@ -54,14 +58,16 @@ def highlight_whitespaces(view): tab_scope_name = hws_settings.get('highlight_whitespaces_tab_highlight_scope_name', DEFAULT_COLOR_SCOPE_NAME) if view.size() <= max_size and not is_find_results(view): - space_regions = find_whitespaces_spaces(view) - view.add_regions('WhitespacesHighlightListener', - space_regions, space_scope_name, '', - sublime.DRAW_EMPTY) - tab_regions = find_whitespaces_tabs(view) - view.add_regions('WhitespacesHighlightListener2', - tab_regions, tab_scope_name, '', - sublime.DRAW_EMPTY) + if hws_settings.get('highlight_whitespaces_check_spaces', DEFAULT_CHECK_SPACES): + space_regions = find_whitespaces_spaces(view) + view.add_regions('WhitespacesHighlightListener', + space_regions, space_scope_name, '', + sublime.DRAW_EMPTY) + if hws_settings.get('highlight_whitespaces_check_tabs', DEFAULT_CHECK_TABS): + tab_regions = find_whitespaces_tabs(view) + view.add_regions('WhitespacesHighlightListener2', + tab_regions, tab_scope_name, '', + sublime.DRAW_EMPTY) # Clear all white spaces diff --git a/highlight_whitespaces.sublime-settings b/highlight_whitespaces.sublime-settings index 41e824a..e35ffb5 100644 --- a/highlight_whitespaces.sublime-settings +++ b/highlight_whitespaces.sublime-settings @@ -1,13 +1,19 @@ { - // Spaces color is determined by scope (default, "invalid") +// Spaces color is determined by scope (default, "invalid") // "highlight_whitespaces_space_highlight_scope_name": "Whitespaces.space.highlight", - // Tabs color is determined by scope (default, "invalid") -// "highlight_whitespaces_tab_highlight_scope_name": "Whitespaces.tab.highlight", +// Tabs color is determined by scope (default, "invalid") +// "highlight_whitespaces_tab_highlight_scope_name": "Whitespaces.tab.highlight", - // Max file size to search +// Max file size to search "highlight_whitespaces_file_max_size": 1048576, - // By default plugin is enabled or disabled (true|false) - "highlight_whitespaces_enabled": true +// By default plugin is enabled or disabled (true|false) + "highlight_whitespaces_enabled": true, + +// Whether to check for spaces + "highlight_whitespaces_check_spaces": true, + +// Whether to check for tabs + "highlight_whitespaces_check_tabs": true }