@@ -19,9 +19,11 @@ import { Event, Emitter } from 'vs/base/common/event';
1919import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
2020import { KeyCode } from 'vs/base/common/keyCodes' ;
2121import { ContextScopedHistoryInputBox } from 'vs/platform/browser/contextScopedHistoryWidget' ;
22- import { attachInputBoxStyler } from 'vs/platform/theme/common/styler' ;
22+ import { attachInputBoxStyler , attachStylerCallback } from 'vs/platform/theme/common/styler' ;
2323import { IThemeService } from 'vs/platform/theme/common/themeService' ;
24+ import { badgeBackground , badgeForeground , contrastBorder } from 'vs/platform/theme/common/colorRegistry' ;
2425import { ReplEvaluationResult , ReplEvaluationInput } from 'vs/workbench/contrib/debug/common/replModel' ;
26+ import { localize } from 'vs/nls' ;
2527
2628
2729type ParsedQuery = {
@@ -84,12 +86,30 @@ export class ReplFilterState {
8486 return this . _onDidChange . event ;
8587 }
8688
89+ private readonly _onDidStatsChange : Emitter < void > = new Emitter < void > ( ) ;
90+ get onDidStatsChange ( ) : Event < void > {
91+ return this . _onDidStatsChange . event ;
92+ }
93+
8794 private _filterText = '' ;
95+ private _stats = { total : 0 , filtered : 0 } ;
8896
8997 get filterText ( ) : string {
9098 return this . _filterText ;
9199 }
92100
101+ get filterStats ( ) : { total : number , filtered : number } {
102+ return this . _stats ;
103+ }
104+
105+ set filterStats ( stats : { total : number , filtered : number } ) {
106+ const { total, filtered } = stats ;
107+ if ( this . _stats . total !== total || this . _stats . filtered !== filtered ) {
108+ this . _stats = { total, filtered } ;
109+ this . _onDidStatsChange . fire ( ) ;
110+ }
111+ }
112+
93113 set filterText ( filterText : string ) {
94114 if ( this . _filterText !== filterText ) {
95115 this . _filterText = filterText ;
@@ -102,6 +122,7 @@ export class ReplFilterActionViewItem extends BaseActionViewItem {
102122
103123 private delayedFilterUpdate : Delayer < void > ;
104124 private container ! : HTMLElement ;
125+ private filterBadge : HTMLElement | null = null ;
105126 private filterInputBox ! : HistoryInputBox ;
106127
107128 constructor (
@@ -123,6 +144,7 @@ export class ReplFilterActionViewItem extends BaseActionViewItem {
123144 this . element = DOM . append ( this . container , DOM . $ ( '' ) ) ;
124145 this . element . className = this . class ;
125146 this . createInput ( this . element ) ;
147+ this . createBadge ( this . element ) ;
126148 this . updateClass ( ) ;
127149 }
128150
@@ -179,6 +201,37 @@ export class ReplFilterActionViewItem extends BaseActionViewItem {
179201 }
180202 }
181203
204+ private createBadge ( container : HTMLElement ) : void {
205+ const controlsContainer = DOM . append ( container , DOM . $ ( '.repl-panel-filter-controls' ) ) ;
206+ const filterBadge = this . filterBadge = DOM . append ( controlsContainer , DOM . $ ( '.repl-panel-filter-badge' ) ) ;
207+ this . _register ( attachStylerCallback ( this . themeService , { badgeBackground, badgeForeground, contrastBorder } , colors => {
208+ const background = colors . badgeBackground ? colors . badgeBackground . toString ( ) : '' ;
209+ const foreground = colors . badgeForeground ? colors . badgeForeground . toString ( ) : '' ;
210+ const border = colors . contrastBorder ? colors . contrastBorder . toString ( ) : '' ;
211+
212+ filterBadge . style . backgroundColor = background ;
213+
214+ filterBadge . style . borderWidth = border ? '1px' : '' ;
215+ filterBadge . style . borderStyle = border ? 'solid' : '' ;
216+ filterBadge . style . borderColor = border ;
217+ filterBadge . style . color = foreground ;
218+ } ) ) ;
219+ this . updateBadge ( ) ;
220+ this . _register ( this . filters . onDidStatsChange ( ( ) => this . updateBadge ( ) ) ) ;
221+ }
222+
223+ private updateBadge ( ) : void {
224+ if ( this . filterBadge ) {
225+ const { total, filtered } = this . filters . filterStats ;
226+ const filterBadgeHidden = total === filtered || filtered === 0 ;
227+
228+ this . filterBadge . classList . toggle ( 'hidden' , filterBadgeHidden ) ;
229+ this . filterBadge . textContent = localize ( 'showing filtered repl lines' , "Showing {0} of {1}" , filtered , total ) ;
230+
231+ this . filterInputBox . inputElement . style . paddingRight = filterBadgeHidden ? '4px' : '150px' ;
232+ }
233+ }
234+
182235 protected get class ( ) : string {
183236 return 'panel-action-tree-filter' ;
184237 }
0 commit comments