@@ -16,6 +16,7 @@ import { IAccessibilityInformation } from 'vs/platform/accessibility/common/acce
16
16
import { IMarkdownString } from 'vs/base/common/htmlContent' ;
17
17
import { getCodiconAriaLabel } from 'vs/base/common/iconLabels' ;
18
18
import { hash } from 'vs/base/common/hash' ;
19
+ import { Event , Emitter } from 'vs/base/common/event' ;
19
20
import { InstantiationType , registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
20
21
import { Iterable } from 'vs/base/common/iterator' ;
21
22
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions' ;
@@ -27,16 +28,24 @@ import { asStatusBarItemIdentifier } from 'vs/workbench/api/common/extHostTypes'
27
28
export const IExtensionStatusBarItemService = createDecorator < IExtensionStatusBarItemService > ( 'IExtensionStatusBarItemService' ) ;
28
29
29
30
export interface IExtensionStatusBarItemChangeEvent {
30
- readonly added ?: Readonly < { entryId : string } & IStatusbarEntry > ;
31
+ readonly added ?: ExtensionStatusBarEntry ;
31
32
readonly removed ?: string ;
32
33
}
33
34
35
+ export type ExtensionStatusBarEntry = [ string , {
36
+ entry : IStatusbarEntry ;
37
+ alignment : MainThreadStatusBarAlignment ;
38
+ priority : number ;
39
+ } ] ;
40
+
34
41
export interface IExtensionStatusBarItemService {
35
42
readonly _serviceBrand : undefined ;
36
43
44
+ onDidChange : Event < IExtensionStatusBarItemChangeEvent > ;
45
+
37
46
setOrUpdateEntry ( id : string , statusId : string , extensionId : string | undefined , name : string , text : string , tooltip : IMarkdownString | string | undefined , command : Command | undefined , color : string | ThemeColor | undefined , backgroundColor : string | ThemeColor | undefined , alignLeft : boolean , priority : number | undefined , accessibilityInformation : IAccessibilityInformation | undefined ) : IDisposable ;
38
47
39
- getEntries ( ) : Iterable < [ string , { entry : IStatusbarEntry ; alignment : MainThreadStatusBarAlignment ; priority : number } ] > ;
48
+ getEntries ( ) : Iterable < ExtensionStatusBarEntry > ;
40
49
}
41
50
42
51
@@ -46,8 +55,17 @@ class ExtensionStatusBarItemService implements IExtensionStatusBarItemService {
46
55
47
56
private readonly _entries : Map < string , { accessor : IStatusbarEntryAccessor ; entry : IStatusbarEntry ; alignment : MainThreadStatusBarAlignment ; priority : number } > = new Map ( ) ;
48
57
58
+ private readonly _onDidChange = new Emitter < IExtensionStatusBarItemChangeEvent > ( ) ;
59
+ readonly onDidChange : Event < IExtensionStatusBarItemChangeEvent > = this . _onDidChange . event ;
60
+
49
61
constructor ( @IStatusbarService private readonly _statusbarService : IStatusbarService ) { }
50
62
63
+ dispose ( ) : void {
64
+ this . _entries . forEach ( entry => entry . accessor . dispose ( ) ) ;
65
+ this . _entries . clear ( ) ;
66
+ this . _onDidChange . dispose ( ) ;
67
+ }
68
+
51
69
setOrUpdateEntry ( entryId : string , id : string , extensionId : string | undefined , name : string , text : string , tooltip : IMarkdownString | string | undefined , command : Command | undefined , color : string | ThemeColor | undefined , backgroundColor : string | ThemeColor | undefined , alignLeft : boolean , priority : number | undefined , accessibilityInformation : IAccessibilityInformation | undefined ) : IDisposable {
52
70
// if there are icons in the text use the tooltip for the aria label
53
71
let ariaLabel : string ;
@@ -98,6 +116,8 @@ class ExtensionStatusBarItemService implements IExtensionStatusBarItemService {
98
116
priority
99
117
} ) ;
100
118
119
+ this . _onDidChange . fire ( { added : [ entryId , { entry, alignment, priority } ] } ) ;
120
+
101
121
} else {
102
122
// Otherwise update
103
123
existingEntry . accessor . update ( entry ) ;
@@ -109,6 +129,7 @@ class ExtensionStatusBarItemService implements IExtensionStatusBarItemService {
109
129
if ( entry ) {
110
130
entry . accessor . dispose ( ) ;
111
131
this . _entries . delete ( entryId ) ;
132
+ this . _onDidChange . fire ( { removed : entryId } ) ;
112
133
}
113
134
} ) ;
114
135
}
0 commit comments