@@ -67,15 +67,6 @@ def persist_settings():
6767 sublime .save_settings (ts_settings_filename )
6868
6969
70- # Private: Determine if the view is a "Find results" view.
71- #
72- # view - the view, you know
73- #
74- # Returns True or False.
75- def is_find_results (view ):
76- return view .settings ().get ('syntax' ) and "Find Results" in view .settings ().get ('syntax' )
77-
78-
7970# Private: Get the regions matching trailing spaces.
8071#
8172# As the core regexp matches lines, the regions are, well, "per lines".
@@ -93,17 +84,23 @@ def find_trailing_spaces(view):
9384 no_empty_lines_regexp = "(?<=\\ S)%s$" % regexp
9485
9586 offending_lines = view .find_all (regexp if include_empty_lines else no_empty_lines_regexp )
87+ ignored_scopes = "," .join (ts_settings .get ("trailing_spaces_scope_ignore" , []))
88+ filtered_lines = []
89+ for region in offending_lines :
90+ if ignored_scopes and view .match_selector (region .begin (), ignored_scopes ):
91+ continue
92+ filtered_lines .append (region )
9693
9794 sel = view .sel ()
9895 line = len (sel ) and view .line (sel [0 ].b )
9996
10097 if include_current_line or not line :
101- return [offending_lines , offending_lines ]
98+ return [filtered_lines , filtered_lines ]
10299 else :
103100 current_offender = view .find (regexp if include_empty_lines else no_empty_lines_regexp , line .a )
104101 removal = False if current_offender is None else line .intersects (current_offender )
105- highlightable = [i for i in offending_lines if i != current_offender ] if removal else offending_lines
106- return [offending_lines , highlightable ]
102+ highlightable = [i for i in filtered_lines if i != current_offender ] if removal else filtered_lines
103+ return [filtered_lines , highlightable ]
107104
108105
109106# Private: Find the freaking trailing spaces in the view and flags them as such!
@@ -128,10 +125,9 @@ def match_trailing_spaces(view):
128125 if max_size_exceeded (view ):
129126 return
130127
131- if not is_find_results (view ):
132- (matched , highlightable ) = find_trailing_spaces (view )
133- add_trailing_spaces_regions (view , matched )
134- highlight_trailing_spaces_regions (view , highlightable )
128+ (matched , highlightable ) = find_trailing_spaces (view )
129+ add_trailing_spaces_regions (view , matched )
130+ highlight_trailing_spaces_regions (view , highlightable )
135131
136132
137133# Private: Checks if the view should be ignored.
0 commit comments