@@ -18,14 +18,14 @@ export type StorageChangeEvent =
1818 /**
1919 * The key of the stored value that has changed.
2020 */
21- readonly key : GlobalStorageKeys ;
21+ readonly keys : GlobalStorageKeys [ ] ;
2222 readonly workspace : false ;
2323 }
2424 | {
2525 /**
2626 * The key of the stored value that has changed.
2727 */
28- readonly key : WorkspaceStorageKeys ;
28+ readonly keys : WorkspaceStorageKeys [ ] ;
2929 readonly workspace : true ;
3030 } ;
3131
@@ -61,7 +61,7 @@ export class Storage implements Disposable {
6161 @debug ( { logThreshold : 250 } )
6262 async delete ( key : GlobalStorageKeys ) : Promise < void > {
6363 await this . context . globalState . update ( `${ extensionPrefix } :${ key } ` , undefined ) ;
64- this . _onDidChange . fire ( { key : key , workspace : false } ) ;
64+ this . _onDidChange . fire ( { keys : [ key ] , workspace : false } ) ;
6565 }
6666
6767 @debug ( { logThreshold : 250 } )
@@ -72,17 +72,23 @@ export class Storage implements Disposable {
7272 async deleteWithPrefixCore ( prefix ?: ExtractPrefixes < GlobalStorageKeys , ':' > , exclude ?: RegExp ) : Promise < void > {
7373 const qualifiedKeyPrefix = `${ extensionPrefix } :` ;
7474
75+ const keys : GlobalStorageKeys [ ] = [ ] ;
76+
7577 for ( const qualifiedKey of this . context . globalState . keys ( ) as `${typeof extensionPrefix } :${GlobalStorageKeys } `[ ] ) {
7678 if ( ! qualifiedKey . startsWith ( qualifiedKeyPrefix ) ) continue ;
7779
7880 const key = qualifiedKey . substring ( qualifiedKeyPrefix . length ) as GlobalStorageKeys ;
7981 if ( prefix == null || key === prefix || key . startsWith ( `${ prefix } :` ) ) {
8082 if ( exclude ?. test ( key ) ) continue ;
8183
84+ keys . push ( key ) ;
8285 await this . context . globalState . update ( qualifiedKey , undefined ) ;
83- this . _onDidChange . fire ( { key : key , workspace : false } ) ;
8486 }
8587 }
88+
89+ if ( keys . length ) {
90+ this . _onDidChange . fire ( { keys : keys , workspace : false } ) ;
91+ }
8692 }
8793
8894 @debug ( { logThreshold : 250 } )
@@ -93,7 +99,7 @@ export class Storage implements Disposable {
9399 @debug ( { args : { 1 : false } , logThreshold : 250 } )
94100 async store < T extends keyof GlobalStorage > ( key : T , value : GlobalStorage [ T ] | undefined ) : Promise < void > {
95101 await this . context . globalState . update ( `${ extensionPrefix } :${ key } ` , value ) ;
96- this . _onDidChange . fire ( { key : key , workspace : false } ) ;
102+ this . _onDidChange . fire ( { keys : [ key ] , workspace : false } ) ;
97103 }
98104
99105 @debug ( { args : false , logThreshold : 250 } )
@@ -123,7 +129,7 @@ export class Storage implements Disposable {
123129 @debug ( { logThreshold : 250 } )
124130 async deleteWorkspace ( key : WorkspaceStorageKeys ) : Promise < void > {
125131 await this . context . workspaceState . update ( `${ extensionPrefix } :${ key } ` , undefined ) ;
126- this . _onDidChange . fire ( { key : key , workspace : true } ) ;
132+ this . _onDidChange . fire ( { keys : [ key ] , workspace : true } ) ;
127133 }
128134
129135 @debug ( { logThreshold : 250 } )
@@ -137,17 +143,23 @@ export class Storage implements Disposable {
137143 ) : Promise < void > {
138144 const qualifiedKeyPrefix = `${ extensionPrefix } :` ;
139145
146+ const keys : WorkspaceStorageKeys [ ] = [ ] ;
147+
140148 for ( const qualifiedKey of this . context . workspaceState . keys ( ) as `${typeof extensionPrefix } :${WorkspaceStorageKeys } `[ ] ) {
141149 if ( ! qualifiedKey . startsWith ( qualifiedKeyPrefix ) ) continue ;
142150
143151 const key = qualifiedKey . substring ( qualifiedKeyPrefix . length ) as WorkspaceStorageKeys ;
144152 if ( prefix == null || key === prefix || key . startsWith ( `${ prefix } :` ) ) {
145153 if ( exclude ?. includes ( key ) ) continue ;
146154
155+ keys . push ( key ) ;
147156 await this . context . workspaceState . update ( qualifiedKey , undefined ) ;
148- this . _onDidChange . fire ( { key : key , workspace : true } ) ;
149157 }
150158 }
159+
160+ if ( keys . length ) {
161+ this . _onDidChange . fire ( { keys : keys , workspace : true } ) ;
162+ }
151163 }
152164
153165 @debug ( { logThreshold : 250 } )
@@ -161,6 +173,6 @@ export class Storage implements Disposable {
161173 value : WorkspaceStorage [ T ] | undefined ,
162174 ) : Promise < void > {
163175 await this . context . workspaceState . update ( `${ extensionPrefix } :${ key } ` , value ) ;
164- this . _onDidChange . fire ( { key : key , workspace : true } ) ;
176+ this . _onDidChange . fire ( { keys : [ key ] , workspace : true } ) ;
165177 }
166178}
0 commit comments