66
77import * as strings from 'vs/base/common/strings' ;
88import * as paths from 'vs/base/common/paths' ;
9+ import * as types from 'vs/base/common/types' ;
910import * as Map from 'vs/base/common/map' ;
1011import Severity from 'vs/base/common/severity' ;
1112import URI from 'vs/base/common/uri' ;
1213import { Range } from 'vs/editor/common/core/range' ;
1314import { IMarker , MarkerStatistics } from 'vs/platform/markers/common/markers' ;
14- import { IFilter , or , matchesContiguousSubString , matchesPrefix } from 'vs/base/common/filters' ;
15+ import { IFilter , IMatch , or , matchesContiguousSubString , matchesPrefix } from 'vs/base/common/filters' ;
1516import Messages from 'vs/workbench/parts/markers/common/messages' ;
1617
1718export class Resource {
1819 public name : string ;
1920 public path : string ;
20- constructor ( public uri : URI , public markers : Marker [ ] , public statistics : MarkerStatistics ) {
21+ constructor ( public uri : URI , public markers : Marker [ ] ,
22+ public statistics : MarkerStatistics ,
23+ public matches : IMatch [ ] = [ ] ) {
2124 this . path = uri . fsPath ;
2225 this . name = paths . basename ( uri . fsPath ) ;
2326 }
2427}
2528
2629export class Marker {
27- static _filter : IFilter = or ( matchesPrefix , matchesContiguousSubString ) ;
28- constructor ( public id :string , public marker : IMarker ) { }
30+ constructor ( public id :string , public marker : IMarker , public labelMatches : IMatch [ ] = [ ] ) { }
2931}
3032
3133export class FilterOptions {
3234
35+ static _filter : IFilter = or ( matchesPrefix , matchesContiguousSubString ) ;
36+
3337 private _filterErrors : boolean = false ;
3438 private _filterWarnings : boolean = false ;
3539 private _filterInfos : boolean = false ;
@@ -130,7 +134,7 @@ export class MarkersModel {
130134 this . updateResource ( arg1 , arg2 ) ;
131135 }
132136
133- if ( arg1 instanceof Array ) {
137+ if ( types . isArray ( arg1 ) ) {
134138 this . updateMarkers ( arg1 ) ;
135139 }
136140
@@ -178,22 +182,21 @@ export class MarkersModel {
178182 }
179183
180184 private toFilteredResource ( entry : Map . Entry < URI , IMarker [ ] > ) {
181- let markers :Marker [ ] = entry . value . filter ( this . filterMarker . bind ( this ) ) . map ( this . toMarker ) ;
185+ let markers :Marker [ ] = entry . value . filter ( this . filterMarker . bind ( this ) ) . map ( ( marker , index ) => {
186+ return this . toMarker ( marker , index ) ;
187+ } ) ;
182188 markers . sort ( this . compareMarkers . bind ( this ) ) ;
183- return new Resource ( entry . key , markers , this . getStatistics ( entry . value ) ) ;
189+ const matches = FilterOptions . _filter ( this . _filterOptions . filter , paths . basename ( entry . key . fsPath ) ) ;
190+ return new Resource ( entry . key , markers , this . getStatistics ( entry . value ) , matches || [ ] ) ;
184191 }
185192
186193 private toMarker ( marker : IMarker , index : number ) :Marker {
187- return new Marker ( marker . resource . toString ( ) + index , marker ) ;
194+ const labelMatches = FilterOptions . _filter ( this . _filterOptions . filter , marker . message ) ;
195+ return new Marker ( marker . resource . toString ( ) + index , marker , labelMatches || [ ] ) ;
188196 }
189197
190198 private filterMarker ( marker : IMarker ) :boolean {
191199 if ( this . _filterOptions . filter ) {
192- const labelHighlights = Marker . _filter ( this . _filterOptions . filter , marker . message ) ;
193- const descHighlights = Marker . _filter ( this . _filterOptions . filter , marker . resource . toString ( ) ) ;
194- if ( ! ! labelHighlights || ! ! descHighlights ) {
195- return true ;
196- }
197200 if ( this . _filterOptions . filterErrors && Severity . Error === marker . severity ) {
198201 return true ;
199202 }
@@ -203,6 +206,12 @@ export class MarkersModel {
203206 if ( this . _filterOptions . filterInfos && Severity . Info === marker . severity ) {
204207 return true ;
205208 }
209+ if ( ! ! FilterOptions . _filter ( this . _filterOptions . filter , marker . message ) ) {
210+ return true ;
211+ }
212+ if ( ! ! FilterOptions . _filter ( this . _filterOptions . filter , paths . basename ( marker . resource . fsPath ) ) ) {
213+ return true ;
214+ }
206215 return false ;
207216 }
208217 return true ;
0 commit comments