@@ -67,15 +67,6 @@ def persist_settings():
67
67
sublime .save_settings (ts_settings_filename )
68
68
69
69
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
-
79
70
# Private: Get the regions matching trailing spaces.
80
71
#
81
72
# As the core regexp matches lines, the regions are, well, "per lines".
@@ -93,17 +84,23 @@ def find_trailing_spaces(view):
93
84
no_empty_lines_regexp = "(?<=\\ S)%s$" % regexp
94
85
95
86
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 )
96
93
97
94
sel = view .sel ()
98
95
line = len (sel ) and view .line (sel [0 ].b )
99
96
100
97
if include_current_line or not line :
101
- return [offending_lines , offending_lines ]
98
+ return [filtered_lines , filtered_lines ]
102
99
else :
103
100
current_offender = view .find (regexp if include_empty_lines else no_empty_lines_regexp , line .a )
104
101
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 ]
107
104
108
105
109
106
# Private: Find the freaking trailing spaces in the view and flags them as such!
@@ -128,10 +125,9 @@ def match_trailing_spaces(view):
128
125
if max_size_exceeded (view ):
129
126
return
130
127
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 )
135
131
136
132
137
133
# Private: Checks if the view should be ignored.
0 commit comments