From 7c8152b0d6cfd5054d5ffb53d1384cda191d7b5a Mon Sep 17 00:00:00 2001 From: Harjeet Singh Date: Mon, 21 Oct 2013 17:20:29 +0530 Subject: [PATCH 1/3] Fixes for ST3 and disabling plugin by default --- highlight_whitespaces.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/highlight_whitespaces.py b/highlight_whitespaces.py index a9b3c1f..888a19b 100644 --- a/highlight_whitespaces.py +++ b/highlight_whitespaces.py @@ -11,7 +11,7 @@ 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": false, "highlight_whitespaces_check_spaces": true, "highlight_whitespaces_check_tabs": true, "highlight_last_whitespace": true @@ -29,7 +29,7 @@ import sublime_plugin DEFAULT_MAX_FILE_SIZE = 1048576 DEFAULT_COLOR_SCOPE_NAME = "invalid" -DEFAULT_IS_ENABLED = True +DEFAULT_IS_ENABLED = False DEFAULT_CHECK_SPACES = True DEFAULT_CHECK_TABS = True DEFAULT_LAST_WHITESPACE = False @@ -39,14 +39,19 @@ hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings') hws_enabled = bool(hws_settings.get('highlight_whitespaces_enabled', DEFAULT_IS_ENABLED)) +def get_settings(): + s = sublime.load_settings('highlight_whitespaces.sublime-settings') + return s + # Determine if the view is a find results view def is_find_results(view): return view.settings().get('syntax') and "Find Results" in view.settings().get('syntax') # Return an array of regions matching whitespaces. def find_whitespaces_spaces(view): + hws_settings = get_settings() last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE)) - regex = ' {2,}|\t | \t' + regex = ' {1,}|\t | \t' if last_whitespace: regex += '| {1,}$' @@ -58,6 +63,8 @@ def find_whitespaces_tabs(view): # Highlight whitespaces def highlight_whitespaces(view): + hws_settings = get_settings() + max_size = hws_settings.get('highlight_whitespaces_file_max_size', DEFAULT_MAX_FILE_SIZE) space_scope_name = hws_settings.get('highlight_whitespaces_space_highlight_scope_name', From 1067d504614d7686c3e285281f9822171345870e Mon Sep 17 00:00:00 2001 From: Harjeet Singh Date: Mon, 21 Oct 2013 17:30:44 +0530 Subject: [PATCH 2/3] Enabling by default again --- highlight_whitespaces.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/highlight_whitespaces.py b/highlight_whitespaces.py index 888a19b..d8af716 100644 --- a/highlight_whitespaces.py +++ b/highlight_whitespaces.py @@ -11,7 +11,7 @@ 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": false, + "highlight_whitespaces_enabled": true, "highlight_whitespaces_check_spaces": true, "highlight_whitespaces_check_tabs": true, "highlight_last_whitespace": true @@ -29,7 +29,7 @@ import sublime_plugin DEFAULT_MAX_FILE_SIZE = 1048576 DEFAULT_COLOR_SCOPE_NAME = "invalid" -DEFAULT_IS_ENABLED = False +DEFAULT_IS_ENABLED = True DEFAULT_CHECK_SPACES = True DEFAULT_CHECK_TABS = True DEFAULT_LAST_WHITESPACE = False From 1df06d1ada83d1bf0c576f7cfe66da95309e2e66 Mon Sep 17 00:00:00 2001 From: Harjeet Singh Date: Mon, 21 Oct 2013 19:14:30 +0530 Subject: [PATCH 3/3] Restored option to allow highlight on single space, but set as false by default --- highlight_whitespaces.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/highlight_whitespaces.py b/highlight_whitespaces.py index d8af716..7d9a467 100644 --- a/highlight_whitespaces.py +++ b/highlight_whitespaces.py @@ -14,6 +14,7 @@ Config summary (see README.md for details): "highlight_whitespaces_enabled": true, "highlight_whitespaces_check_spaces": true, "highlight_whitespaces_check_tabs": true, + "highlight_whitespaces_single_space": false, "highlight_last_whitespace": true } @@ -31,6 +32,7 @@ DEFAULT_MAX_FILE_SIZE = 1048576 DEFAULT_COLOR_SCOPE_NAME = "invalid" DEFAULT_IS_ENABLED = True DEFAULT_CHECK_SPACES = True +DEFAULT_SINGLE_SPACE = False DEFAULT_CHECK_TABS = True DEFAULT_LAST_WHITESPACE = False @@ -51,9 +53,13 @@ def is_find_results(view): def find_whitespaces_spaces(view): hws_settings = get_settings() last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE)) - regex = ' {1,}|\t | \t' - if last_whitespace: - regex += '| {1,}$' + single_space = bool(hws_settings.get('highlight_whitespaces_single_space',DEFAULT_SINGLE_SPACE)) + if single_space: + regex = ' +' + else: + regex = ' {2,}|\t | \t' + if last_whitespace: + regex += '| {1,}$' return view.find_all(regex)