Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions trailing_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Highlight color as defined in settings. Plugin mutates that setting when disabled so
# that has to be stored.
INITIAL_HIGHLIGHT_COLOR = None
HIGHLIGHT_REGION_KEY = 'TrailingSpacesHighlightedRegions'
settings = None


Expand Down Expand Up @@ -198,12 +199,9 @@ def max_size_exceeded(view):
#
# Returns nothing.
def highlight_trailing_spaces_regions(view, regions):
view.erase_regions("TrailingSpacesHighlightedRegions")
view.add_regions('TrailingSpacesHighlightedRegions',
regions,
current_highlight_color or "",
"",
sublime.HIDE_ON_MINIMAP)
view.erase_regions(HIGHLIGHT_REGION_KEY)
if regions:
view.add_regions(HIGHLIGHT_REGION_KEY, regions, current_highlight_color or "", "", sublime.HIDE_ON_MINIMAP)


# Private: Toggles highlighting of all trailing spaces in the view.
Expand All @@ -228,7 +226,7 @@ def toggle_highlighting(view):

scope = INITIAL_HIGHLIGHT_COLOR if current_highlight_color == "" else ""
current_highlight_color = scope
highlight_trailing_spaces_regions(view, view.get_regions('TrailingSpacesHighlightedRegions'))
highlight_trailing_spaces_regions(view, view.get_regions(HIGHLIGHT_REGION_KEY))
return "off" if current_highlight_color == "" else "on"


Expand Down