33
33
INITIAL_HIGHLIGHT_COLOR = None
34
34
HIGHLIGHT_REGION_KEY = 'TrailingSpacesHighlightedRegions'
35
35
settings = None
36
+ named_settings = None
36
37
37
38
38
39
def plugin_loaded ():
39
- global settings , current_highlight_color , INITIAL_HIGHLIGHT_COLOR
40
+ global settings , named_settings , current_highlight_color , INITIAL_HIGHLIGHT_COLOR
40
41
41
- # A settings layer that handled settings that included `trailing_spaces_` prefix (now deprecated).
42
+ # A settings layer that handles settings with the `trailing_spaces_` prefix (now deprecated).
42
43
class DeprecatedSettingsDict (NamedSettingsDict ):
43
44
def __getitem__ (self , key ):
44
45
return super ().__getitem__ ('trailing_spaces_%s' % key )
45
46
46
47
deprecated_settings = DeprecatedSettingsDict (SETTINGS_FILENAME )
47
- settings = ChainMap (deprecated_settings , NamedSettingsDict (SETTINGS_FILENAME ), DEFAULT_SETTINGS )
48
+ named_settings = NamedSettingsDict (SETTINGS_FILENAME )
49
+ settings = ChainMap (deprecated_settings , named_settings , DEFAULT_SETTINGS )
48
50
49
51
current_highlight_color = settings ['highlight_color' ]
50
52
INITIAL_HIGHLIGHT_COLOR = current_highlight_color
51
53
52
54
if not settings ['enabled' ]:
53
55
current_highlight_color = ""
54
56
if settings ['highlight_color' ] != current_highlight_color :
55
- settings [ 0 ] .save ()
57
+ named_settings .save ()
56
58
57
59
58
60
# Private: Makes sure all timers are stopped.
@@ -376,8 +378,8 @@ def run(self):
376
378
return
377
379
378
380
state = toggle_highlighting (view )
379
- settings ['highlight_color' ] = current_highlight_color
380
- settings [ 0 ] .save ()
381
+ named_settings ['highlight_color' ] = current_highlight_color
382
+ named_settings .save ()
381
383
sublime .status_message ('Highlighting of trailing spaces is %s' % state )
382
384
383
385
def is_checked (self ):
@@ -388,8 +390,8 @@ def is_checked(self):
388
390
class ToggleTrailingSpacesModifiedLinesOnlyCommand (sublime_plugin .WindowCommand ):
389
391
def run (self ):
390
392
was_on = settings ['modified_lines_only' ]
391
- settings ['modified_lines_only' ] = not was_on
392
- settings [ 0 ] .save ()
393
+ named_settings ['modified_lines_only' ] = not was_on
394
+ named_settings .save ()
393
395
394
396
message = "Let's trim trailing spaces everywhere" if was_on \
395
397
else "Let's trim trailing spaces only on modified lines"
0 commit comments