3333INITIAL_HIGHLIGHT_COLOR = None
3434HIGHLIGHT_REGION_KEY = 'TrailingSpacesHighlightedRegions'
3535settings = None
36+ named_settings = None
3637
3738
3839def plugin_loaded ():
39- global settings , current_highlight_color , INITIAL_HIGHLIGHT_COLOR
40+ global settings , named_settings , current_highlight_color , INITIAL_HIGHLIGHT_COLOR
4041
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).
4243 class DeprecatedSettingsDict (NamedSettingsDict ):
4344 def __getitem__ (self , key ):
4445 return super ().__getitem__ ('trailing_spaces_%s' % key )
4546
4647 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 )
4850
4951 current_highlight_color = settings ['highlight_color' ]
5052 INITIAL_HIGHLIGHT_COLOR = current_highlight_color
5153
5254 if not settings ['enabled' ]:
5355 current_highlight_color = ""
5456 if settings ['highlight_color' ] != current_highlight_color :
55- settings [ 0 ] .save ()
57+ named_settings .save ()
5658
5759
5860# Private: Makes sure all timers are stopped.
@@ -376,8 +378,8 @@ def run(self):
376378 return
377379
378380 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 ()
381383 sublime .status_message ('Highlighting of trailing spaces is %s' % state )
382384
383385 def is_checked (self ):
@@ -388,8 +390,8 @@ def is_checked(self):
388390class ToggleTrailingSpacesModifiedLinesOnlyCommand (sublime_plugin .WindowCommand ):
389391 def run (self ):
390392 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 ()
393395
394396 message = "Let's trim trailing spaces everywhere" if was_on \
395397 else "Let's trim trailing spaces only on modified lines"
0 commit comments