@@ -64,11 +64,16 @@ let cachedSyncIgnoredSettings: string[] = [];
64
64
export class SettingsTreeIndicatorsLabel implements IDisposable {
65
65
private readonly indicatorsContainerElement : HTMLElement ;
66
66
67
+ private readonly previewIndicator : SettingIndicator ;
67
68
private readonly workspaceTrustIndicator : SettingIndicator ;
68
69
private readonly scopeOverridesIndicator : SettingIndicator ;
69
70
private readonly syncIgnoredIndicator : SettingIndicator ;
70
71
private readonly defaultOverrideIndicator : SettingIndicator ;
71
- private readonly allIndicators : SettingIndicator [ ] ;
72
+
73
+ /** Indicators that each have their own square container at the top-right of the setting */
74
+ private readonly isolatedIndicators : SettingIndicator [ ] = [ ] ;
75
+ /** Indicators that end up wrapped in a parenthesis at the top-right of the setting */
76
+ private readonly parenthesizedIndicators : SettingIndicator [ ] ;
72
77
73
78
private readonly keybindingListeners : DisposableStore = new DisposableStore ( ) ;
74
79
private focusedIndex = 0 ;
@@ -83,11 +88,14 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
83
88
this . indicatorsContainerElement = DOM . append ( container , $ ( '.setting-indicators-container' ) ) ;
84
89
this . indicatorsContainerElement . style . display = 'inline' ;
85
90
91
+ this . previewIndicator = this . createPreviewIndicator ( ) ;
92
+ this . isolatedIndicators = [ this . previewIndicator ] ;
93
+
86
94
this . workspaceTrustIndicator = this . createWorkspaceTrustIndicator ( ) ;
87
95
this . scopeOverridesIndicator = this . createScopeOverridesIndicator ( ) ;
88
96
this . syncIgnoredIndicator = this . createSyncIgnoredIndicator ( ) ;
89
97
this . defaultOverrideIndicator = this . createDefaultOverrideIndicator ( ) ;
90
- this . allIndicators = [ this . workspaceTrustIndicator , this . scopeOverridesIndicator , this . syncIgnoredIndicator , this . defaultOverrideIndicator ] ;
98
+ this . parenthesizedIndicators = [ this . workspaceTrustIndicator , this . scopeOverridesIndicator , this . syncIgnoredIndicator , this . defaultOverrideIndicator ] ;
91
99
}
92
100
93
101
private defaultHoverOptions : Partial < IHoverOptions > = {
@@ -206,24 +214,46 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
206
214
} ;
207
215
}
208
216
217
+ private createPreviewIndicator ( ) : SettingIndicator {
218
+ const disposables = new DisposableStore ( ) ;
219
+ const previewIndicator = $ ( 'span.setting-indicator.setting-item-preview' ) ;
220
+ const previewLabel = disposables . add ( new SimpleIconLabel ( previewIndicator ) ) ;
221
+
222
+ return {
223
+ element : previewIndicator ,
224
+ label : previewLabel ,
225
+ disposables
226
+ } ;
227
+ }
228
+
209
229
private render ( ) {
210
- const indicatorsToShow = this . allIndicators . filter ( indicator => {
230
+ this . indicatorsContainerElement . innerText = '' ;
231
+ this . indicatorsContainerElement . style . display = 'none' ;
232
+
233
+ const isolatedIndicatorsToShow = this . isolatedIndicators . filter ( indicator => {
211
234
return indicator . element . style . display !== 'none' ;
212
235
} ) ;
236
+ if ( isolatedIndicatorsToShow . length ) {
237
+ this . indicatorsContainerElement . style . display = 'inline' ;
238
+ for ( let i = 0 ; i < isolatedIndicatorsToShow . length ; i ++ ) {
239
+ DOM . append ( this . indicatorsContainerElement , isolatedIndicatorsToShow [ i ] . element ) ;
240
+ }
241
+ }
213
242
214
- this . indicatorsContainerElement . innerText = '' ;
215
- this . indicatorsContainerElement . style . display = 'none' ;
216
- if ( indicatorsToShow . length ) {
243
+ const parenthesizedIndicatorsToShow = this . parenthesizedIndicators . filter ( indicator => {
244
+ return indicator . element . style . display !== 'none' ;
245
+ } ) ;
246
+ if ( parenthesizedIndicatorsToShow . length ) {
217
247
this . indicatorsContainerElement . style . display = 'inline' ;
218
248
DOM . append ( this . indicatorsContainerElement , $ ( 'span' , undefined , '(' ) ) ;
219
- for ( let i = 0 ; i < indicatorsToShow . length - 1 ; i ++ ) {
220
- DOM . append ( this . indicatorsContainerElement , indicatorsToShow [ i ] . element ) ;
249
+ for ( let i = 0 ; i < parenthesizedIndicatorsToShow . length - 1 ; i ++ ) {
250
+ DOM . append ( this . indicatorsContainerElement , parenthesizedIndicatorsToShow [ i ] . element ) ;
221
251
DOM . append ( this . indicatorsContainerElement , $ ( 'span.comma' , undefined , ' • ' ) ) ;
222
252
}
223
- DOM . append ( this . indicatorsContainerElement , indicatorsToShow [ indicatorsToShow . length - 1 ] . element ) ;
253
+ DOM . append ( this . indicatorsContainerElement , parenthesizedIndicatorsToShow [ parenthesizedIndicatorsToShow . length - 1 ] . element ) ;
224
254
DOM . append ( this . indicatorsContainerElement , $ ( 'span' , undefined , ')' ) ) ;
225
- this . resetIndicatorNavigationKeyBindings ( indicatorsToShow ) ;
226
255
}
256
+ this . resetIndicatorNavigationKeyBindings ( [ ...isolatedIndicatorsToShow , ...parenthesizedIndicatorsToShow ] ) ;
227
257
}
228
258
229
259
private resetIndicatorNavigationKeyBindings ( indicators : SettingIndicator [ ] ) {
@@ -289,6 +319,30 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
289
319
}
290
320
}
291
321
322
+ updatePreviewIndicator ( element : SettingsTreeSettingElement ) {
323
+ const isPreviewSetting = element . tags ?. has ( 'preview' ) ;
324
+ // Hide experimental indicators for now until further review and experimental -> onExP migration.
325
+ const isExperimentalSetting = false ; // element.tags?.has('experimental');
326
+ this . previewIndicator . element . style . display = ( isPreviewSetting || isExperimentalSetting ) ? 'inline' : 'none' ;
327
+ this . previewIndicator . label . text = isPreviewSetting ?
328
+ localize ( 'previewLabel' , "Preview" ) :
329
+ localize ( 'experimentalLabel' , "Experimental" ) ;
330
+
331
+ const content = isPreviewSetting ?
332
+ localize ( 'previewSettingDescription' , "The setting is in the process of becoming stable." ) :
333
+ localize ( 'experimentalSettingDescription' , "The setting is experimental and may change names or be removed." ) ;
334
+ const showHover = ( focus : boolean ) => {
335
+ return this . hoverService . showHover ( {
336
+ ...this . defaultHoverOptions ,
337
+ content,
338
+ target : this . previewIndicator . element
339
+ } , focus ) ;
340
+ } ;
341
+ this . addHoverDisposables ( this . previewIndicator . disposables , this . previewIndicator . element , showHover ) ;
342
+
343
+ this . render ( ) ;
344
+ }
345
+
292
346
private getInlineScopeDisplayText ( completeScope : string ) : string {
293
347
const [ scope , language ] = completeScope . split ( ':' ) ;
294
348
const localizedScope = scope === 'user' ?
@@ -302,7 +356,10 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
302
356
303
357
dispose ( ) {
304
358
this . keybindingListeners . dispose ( ) ;
305
- for ( const indicator of this . allIndicators ) {
359
+ for ( const indicator of this . isolatedIndicators ) {
360
+ indicator . disposables . dispose ( ) ;
361
+ }
362
+ for ( const indicator of this . parenthesizedIndicators ) {
306
363
indicator . disposables . dispose ( ) ;
307
364
}
308
365
}
0 commit comments