@@ -169,7 +169,12 @@ class VirtualObjectFile implements FileProvider {
169
169
const value = ( await this . storage . get ( key ) ) ?? ''
170
170
return JSON . stringify ( JSON . parse ( value ) , undefined , 4 )
171
171
} else {
172
- return JSON . stringify ( this . storage . get ( key , { } ) , undefined , 4 )
172
+ if ( key !== '' ) {
173
+ return JSON . stringify ( this . storage . get ( key , { } ) , undefined , 4 )
174
+ }
175
+ // lol hax
176
+ // as of November 2023, all of a memento's properties are stored as property `f` when minified
177
+ return JSON . stringify ( ( this . storage as any ) . f , undefined , 4 )
173
178
}
174
179
}
175
180
@@ -226,14 +231,24 @@ class ObjectEditor {
226
231
}
227
232
228
233
private async createTab ( storage : vscode . Memento | vscode . SecretStorage , key : string ) : Promise < Tab > {
229
- const uri = this . uriFromKey ( key , storage )
230
- const disposable = this . fs . registerProvider ( uri , new VirtualObjectFile ( storage , key ) )
231
- const document = await vscode . workspace . openTextDocument ( uri )
234
+ const virtualFile = new VirtualObjectFile ( storage , key )
235
+ let disposable : vscode . Disposable
236
+ let document : vscode . TextDocument
237
+ if ( key !== '' ) {
238
+ const uri = this . uriFromKey ( key , storage )
239
+ disposable = this . fs . registerProvider ( uri , virtualFile )
240
+ document = await vscode . workspace . openTextDocument ( uri )
241
+ } else {
242
+ // don't tie it to a URI so you can't save this view
243
+ const stream = await virtualFile . read ( )
244
+ document = await vscode . workspace . openTextDocument ( {
245
+ content : new TextDecoder ( ) . decode ( stream ) ,
246
+ } )
247
+ }
232
248
const withLanguage = await vscode . languages . setTextDocumentLanguage ( document , 'json' )
233
- const editor = await vscode . window . showTextDocument ( withLanguage )
234
249
235
250
return {
236
- editor,
251
+ editor : await vscode . window . showTextDocument ( withLanguage ) ,
237
252
dispose : ( ) => disposable . dispose ( ) ,
238
253
}
239
254
}
@@ -247,7 +262,7 @@ class ObjectEditor {
247
262
}
248
263
}
249
264
250
- async function openStorageFromInput ( ) {
265
+ async function openStorageFromInput ( ctx : ExtContext ) {
251
266
const wizard = new ( class extends Wizard < { target : 'globals' | 'secrets' ; key : string } > {
252
267
constructor ( ) {
253
268
super ( )
@@ -264,12 +279,33 @@ async function openStorageFromInput() {
264
279
)
265
280
)
266
281
267
- this . form . key . bindPrompter ( ( { target } ) =>
268
- createInputBox ( {
269
- title : 'Enter a key' ,
270
- placeholder : target === 'globals' ? 'region' : '' ,
271
- } )
272
- )
282
+ this . form . key . bindPrompter ( ( { target } ) => {
283
+ if ( target === 'secrets' ) {
284
+ return createInputBox ( {
285
+ title : 'Enter a key' ,
286
+ } )
287
+ } else if ( target === 'globals' ) {
288
+ const items = ctx . extensionContext . globalState
289
+ . keys ( )
290
+ . map ( key => {
291
+ return {
292
+ label : key ,
293
+ data : key ,
294
+ }
295
+ } )
296
+ . sort ( ( a , b ) => {
297
+ return a . data . localeCompare ( b . data )
298
+ } )
299
+ items . unshift ( {
300
+ data : '' ,
301
+ label : "SHOW ALL (edits here won't write to global state)" ,
302
+ } )
303
+
304
+ return createQuickPick ( items , { title : 'Pick a global state key' } )
305
+ } else {
306
+ throw new Error ( 'invalid storage target' )
307
+ }
308
+ } )
273
309
}
274
310
} ) ( )
275
311
0 commit comments