diff --git a/src/vs/workbench/contrib/markers/browser/markersFilterOptions.ts b/src/vs/workbench/contrib/markers/browser/markersFilterOptions.ts index f93e78768d8b1..0e1913da89290 100644 --- a/src/vs/workbench/contrib/markers/browser/markersFilterOptions.ts +++ b/src/vs/workbench/contrib/markers/browser/markersFilterOptions.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import Messages from 'vs/workbench/contrib/markers/browser/messages'; -import { IFilter, matchesPrefix, matchesFuzzy, matchesFuzzy2 } from 'vs/base/common/filters'; +import { IFilter, matchesFuzzy, matchesFuzzy2 } from 'vs/base/common/filters'; import { IExpression, splitGlobAware, getEmptyExpression } from 'vs/base/common/glob'; import * as strings from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; @@ -15,15 +14,18 @@ export class FilterOptions { static readonly _filter: IFilter = matchesFuzzy2; static readonly _messageFilter: IFilter = matchesFuzzy; - readonly filterErrors: boolean = false; - readonly filterWarnings: boolean = false; - readonly filterInfos: boolean = false; + readonly _showWarnings: boolean = false; + readonly _showErrors: boolean = false; + readonly _showInfos: boolean = false; readonly textFilter: string = ''; readonly excludesMatcher: ResourceGlobMatcher; readonly includesMatcher: ResourceGlobMatcher; - constructor(readonly filter: string = '', filesExclude: { root: URI, expression: IExpression }[] | IExpression = []) { + constructor(readonly filter: string = '', filesExclude: { root: URI, expression: IExpression }[] | IExpression = [], readonly showWarnings: boolean = false, readonly showErrors: boolean = false, readonly showInfos: boolean = false) { filter = filter.trim(); + this._showWarnings = showWarnings; + this._showErrors = showErrors; + this._showInfos = showInfos; const filesExcludeByRoot = Array.isArray(filesExclude) ? filesExclude : []; const excludesExpression: IExpression = Array.isArray(filesExclude) ? getEmptyExpression() : filesExclude; @@ -32,9 +34,6 @@ export class FilterOptions { if (filter) { const filters = splitGlobAware(filter, ',').map(s => s.trim()).filter(s => !!s.length); for (const f of filters) { - this.filterErrors = this.filterErrors || this.matches(f, Messages.MARKERS_PANEL_FILTER_ERRORS); - this.filterWarnings = this.filterWarnings || this.matches(f, Messages.MARKERS_PANEL_FILTER_WARNINGS); - this.filterInfos = this.filterInfos || this.matches(f, Messages.MARKERS_PANEL_FILTER_INFOS); if (strings.startsWith(f, '!')) { this.setPattern(excludesExpression, strings.ltrim(f, '!')); } else { @@ -56,9 +55,4 @@ export class FilterOptions { expression[`**/${pattern}/**`] = true; expression[`**/${pattern}`] = true; } - - private matches(prefix: string, word: string): boolean { - const result = matchesPrefix(prefix, word); - return !!(result && result.length > 0); - } } diff --git a/src/vs/workbench/contrib/markers/browser/markersPanel.ts b/src/vs/workbench/contrib/markers/browser/markersPanel.ts index c52ac3dc461b5..0e6850b3c2ac0 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanel.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanel.ts @@ -274,7 +274,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { private updateFilter() { this.cachedFilterStats = undefined; - this.filter.options = new FilterOptions(this.filterAction.filterText, this.getFilesExcludeExpressions()); + this.filter.options = new FilterOptions(this.filterAction.filterText, this.getFilesExcludeExpressions(), this.filterAction.showWarnings, this.filterAction.showErrors, this.filterAction.showInfos); this.tree.refilter(); this._onDidFilter.fire(); @@ -420,7 +420,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { })); this._register(this.tree.onDidChangeSelection(() => this.onSelected())); this._register(this.filterAction.onDidChange((event: IMarkersFilterActionChangeEvent) => { - if (event.filterText || event.useFilesExclude) { + if (event.filterText || event.useFilesExclude || event.showWarnings || event.showErrors || event.showInfos) { this.updateFilter(); } })); diff --git a/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts b/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts index 20191e50f1ce1..1777add0a2e24 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts @@ -65,6 +65,9 @@ export class ShowProblemsPanelAction extends Action { export interface IMarkersFilterActionChangeEvent extends IActionChangeEvent { filterText?: boolean; useFilesExclude?: boolean; + showWarnings?: boolean; + showErrors?: boolean; + showInfos?: boolean; } export interface IMarkersFilterActionOptions { @@ -111,6 +114,39 @@ export class MarkersFilterAction extends Action { } } + private _showWarnings: boolean = true; + get showWarnings(): boolean { + return this._showWarnings; + } + set showWarnings(showWarnings: boolean) { + if (this._showWarnings !== showWarnings) { + this._showWarnings = showWarnings; + this._onDidChange.fire({ showWarnings: true }); + } + } + + private _showErrors: boolean = true; + get showErrors(): boolean { + return this._showErrors; + } + set showErrors(showErrors: boolean) { + if (this._showErrors !== showErrors) { + this._showErrors = showErrors; + this._onDidChange.fire({ showErrors: true }); + } + } + + private _showInfos: boolean = true; + get showInfos(): boolean { + return this._showInfos; + } + set showInfos(showInfos: boolean) { + if (this._showInfos !== showInfos) { + this._showInfos = showInfos; + this._onDidChange.fire({ showInfos: true }); + } + } + focus(): void { this._onFocus.fire(); } @@ -203,6 +239,9 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem { const controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls')); this.createBadge(controlsContainer); this.createFilesExcludeCheckbox(controlsContainer); + this.createErrorsCheckbox(controlsContainer); + this.createWarningsCheckbox(controlsContainer); + this.createInfosCheckbox(controlsContainer); } private createBadge(container: HTMLElement): void { @@ -244,6 +283,69 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem { container.appendChild(filesExcludeFilter.domNode); } + private createWarningsCheckbox(container: HTMLElement): void { + const warningsFilter = this._register(new Checkbox({ + actionClassName: 'codicon codicon-warning', + title: this.action.showWarnings ? Messages.MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_WARNINGS : Messages.MARKERS_PANEL_ACTION_TOOLTIP_SHOW_WARNINGS, + isChecked: this.action.showWarnings + })); + this._register(warningsFilter.onChange(() => { + warningsFilter.domNode.title = warningsFilter.checked ? Messages.MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_WARNINGS : Messages.MARKERS_PANEL_ACTION_TOOLTIP_SHOW_WARNINGS; + this.action.showWarnings = warningsFilter.checked; + this.focus(); + })); + this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => { + if (event.showWarnings) { + warningsFilter.checked = this.action.showWarnings; + } + })); + + this._register(attachCheckboxStyler(warningsFilter, this.themeService)); + container.appendChild(warningsFilter.domNode); + } + + private createErrorsCheckbox(container: HTMLElement): void { + const errorsFilter = this._register(new Checkbox({ + actionClassName: 'codicon codicon-error', + title: this.action.showErrors ? Messages.MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_ERRORS : Messages.MARKERS_PANEL_ACTION_TOOLTIP_SHOW_ERRORS, + isChecked: this.action.showErrors + })); + this._register(errorsFilter.onChange(() => { + errorsFilter.domNode.title = errorsFilter.checked ? Messages.MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_ERRORS : Messages.MARKERS_PANEL_ACTION_TOOLTIP_SHOW_ERRORS; + this.action.showErrors = errorsFilter.checked; + this.focus(); + })); + this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => { + if (event.showErrors) { + errorsFilter.checked = this.action.showErrors; + } + })); + + this._register(attachCheckboxStyler(errorsFilter, this.themeService)); + container.appendChild(errorsFilter.domNode); + } + + private createInfosCheckbox(container: HTMLElement): void { + const infosFilter = this._register(new Checkbox({ + actionClassName: 'codicon codicon-info', + title: this.action.showInfos ? Messages.MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_INFOS : Messages.MARKERS_PANEL_ACTION_TOOLTIP_SHOW_INFOS, + isChecked: this.action.showInfos + })); + this._register(infosFilter.onChange(() => { + infosFilter.domNode.title = infosFilter.checked ? Messages.MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_INFOS : Messages.MARKERS_PANEL_ACTION_TOOLTIP_SHOW_INFOS; + this.action.showInfos = infosFilter.checked; + this.focus(); + })); + this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => { + if (event.showInfos) { + infosFilter.checked = this.action.showInfos; + } + })); + + this._register(attachCheckboxStyler(infosFilter, this.themeService)); + container.appendChild(infosFilter.domNode); + } + private onDidInputChange(inputbox: HistoryInputBox) { inputbox.addToHistory(); this.action.filterText = inputbox.value; @@ -292,9 +394,9 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem { private reportFilteringUsed(): void { const filterOptions = this.filterController.getFilterOptions(); const data = { - errors: filterOptions.filterErrors, - warnings: filterOptions.filterWarnings, - infos: filterOptions.filterInfos, + errors: filterOptions._showErrors, + warnings: filterOptions._showWarnings, + infos: filterOptions._showInfos, }; /* __GDPR__ "problems.filter" : { diff --git a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts index a379c7bb58a07..8bb9e9164f55a 100644 --- a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts +++ b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts @@ -425,16 +425,21 @@ export class Filter implements ITreeFilter { } private filterMarker(marker: Marker, parentVisibility: TreeVisibility): TreeFilterResult { - if (this.options.filterErrors && MarkerSeverity.Error === marker.marker.severity) { - return true; + let shouldAppear: boolean = false; + if (this.options._showErrors && MarkerSeverity.Error === marker.marker.severity) { + shouldAppear = true; } - if (this.options.filterWarnings && MarkerSeverity.Warning === marker.marker.severity) { - return true; + if (this.options._showWarnings && MarkerSeverity.Warning === marker.marker.severity) { + shouldAppear = true; } - if (this.options.filterInfos && MarkerSeverity.Info === marker.marker.severity) { - return true; + if (this.options._showInfos && MarkerSeverity.Info === marker.marker.severity) { + shouldAppear = true; + } + + if (!shouldAppear) { + return false; } if (!this.options.textFilter) { diff --git a/src/vs/workbench/contrib/markers/browser/messages.ts b/src/vs/workbench/contrib/markers/browser/messages.ts index 0dc99d4f066a9..9b9d87c04813f 100644 --- a/src/vs/workbench/contrib/markers/browser/messages.ts +++ b/src/vs/workbench/contrib/markers/browser/messages.ts @@ -25,6 +25,12 @@ export default class Messages { public static MARKERS_PANEL_ACTION_TOOLTIP_USE_FILES_EXCLUDE: string = nls.localize('markers.panel.action.useFilesExclude', "Filter using Files Exclude Setting"); public static MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_USE_FILES_EXCLUDE: string = nls.localize('markers.panel.action.donotUseFilesExclude', "Do not use Files Exclude Setting"); + public static MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_WARNINGS: string = nls.localize('markers.panel.action.donotShowWarnings', "Do not show warnings"); + public static MARKERS_PANEL_ACTION_TOOLTIP_SHOW_WARNINGS: string = nls.localize('markers.panel.action.showWarnings', "Show warnings"); + public static MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_ERRORS: string = nls.localize('markers.panel.action.donotShowErrors', "Do not show errors"); + public static MARKERS_PANEL_ACTION_TOOLTIP_SHOW_ERRORS: string = nls.localize('markers.panel.action.showErrors', "Show errors"); + public static MARKERS_PANEL_ACTION_TOOLTIP_DO_NOT_SHOW_INFOS: string = nls.localize('markers.panel.action.donotShowInfos', "Do not show infos"); + public static MARKERS_PANEL_ACTION_TOOLTIP_SHOW_INFOS: string = nls.localize('markers.panel.action.showInfos', "Show infos"); public static MARKERS_PANEL_ACTION_TOOLTIP_FILTER: string = nls.localize('markers.panel.action.filter', "Filter Problems"); public static MARKERS_PANEL_ACTION_TOOLTIP_QUICKFIX: string = nls.localize('markers.panel.action.quickfix', "Show fixes"); public static MARKERS_PANEL_FILTER_ARIA_LABEL: string = nls.localize('markers.panel.filter.ariaLabel', "Filter Problems");