@@ -58,7 +58,7 @@ export class TestMessage<T extends vscode.MessageItem = vscode.MessageItem> {
58
58
}
59
59
60
60
public get visible ( ) {
61
- return this . _showing && this . message
61
+ return this . _showing && ! ! this . message
62
62
}
63
63
64
64
public get detail ( ) {
@@ -140,7 +140,11 @@ export class TestMessage<T extends vscode.MessageItem = vscode.MessageItem> {
140
140
}
141
141
142
142
public printDebug ( message : string | RegExp = this . message , severity = this . severity ) {
143
- return `[${ severity } ]: ${ typeof message === 'string' ? message : message . source } `
143
+ return [
144
+ `severity: ${ severity } ` ,
145
+ `message: ${ message } ` ,
146
+ `items: ${ this . options ?. items ?. map ( i => i . title ) . join ( ', ' ) || '[no items]' } ` ,
147
+ ] . join ( ', ' )
144
148
}
145
149
146
150
public dispose ( ) : void {
@@ -166,7 +170,7 @@ export class TestMessage<T extends vscode.MessageItem = vscode.MessageItem> {
166
170
throw new Error ( 'Attempted to select from a disposed message' )
167
171
}
168
172
if ( ! this . options ?. items || this . options . items . length === 0 ) {
169
- throw new Error ( `Could not find the specified item: ${ item } . Message has no items: ${ this . message } ` )
173
+ throw new Error ( `Could not find the specified item " ${ item } " . Message has no items: ${ this . message } ` )
170
174
}
171
175
172
176
const selected =
@@ -175,8 +179,7 @@ export class TestMessage<T extends vscode.MessageItem = vscode.MessageItem> {
175
179
: this . options ?. items ?. find ( i => i === item )
176
180
177
181
if ( ! selected ) {
178
- const items = this . options ?. items ?. map ( i => i . title ) ?. join ( '\n' )
179
- throw new Error ( `Could not find the specified item: ${ item } . Current items:\n${ items } ` )
182
+ throw new Error ( `Could not find the specified item "${ item } " on message: ${ this . printDebug ( ) } ` )
180
183
}
181
184
182
185
this . _selected = selected
@@ -243,11 +246,11 @@ export class TestMessage<T extends vscode.MessageItem = vscode.MessageItem> {
243
246
}
244
247
245
248
interface OpenDialogOptions extends vscode . OpenDialogOptions {
246
- readonly type : 'open '
249
+ readonly type : 'Open '
247
250
}
248
251
249
252
interface SaveDialogOptions extends vscode . SaveDialogOptions {
250
- readonly type : 'save '
253
+ readonly type : 'Save '
251
254
}
252
255
253
256
type FileSystemDialogOptions = OpenDialogOptions | SaveDialogOptions
@@ -294,7 +297,7 @@ export class TestFileSystemDialog {
294
297
}
295
298
296
299
public get acceptButtonLabel ( ) {
297
- if ( this . options . type === 'save ' ) {
300
+ if ( this . options . type === 'Save ' ) {
298
301
return this . options . saveLabel
299
302
} else {
300
303
return this . options . openLabel
@@ -343,12 +346,20 @@ export class TestFileSystemDialog {
343
346
} )
344
347
}
345
348
349
+ public printDebug ( ) {
350
+ return [
351
+ `type: ${ this . options . type } ` ,
352
+ `title: ${ this . title ?? '[no title]' } ` ,
353
+ `acceptButtonLabel: ${ this . acceptButtonLabel ?? '[no label]' } ` ,
354
+ ] . join ( ', ' )
355
+ }
356
+
346
357
public static createOpenSaveDialogFn (
347
358
fs : vscode . FileSystem ,
348
359
callback ?: ( dialog : TestFileSystemDialog ) => void
349
360
) : Window [ 'showOpenDialog' ] {
350
361
return async ( options ?: vscode . OpenDialogOptions ) => {
351
- const dialog = new TestFileSystemDialog ( [ ] , { type : 'open ' , ...options } )
362
+ const dialog = new TestFileSystemDialog ( [ ] , { type : 'Open ' , ...options } )
352
363
353
364
return new Promise < vscode . Uri [ ] | undefined > ( resolve => {
354
365
dialog . onDidAcceptItem ( item => resolve ( item instanceof vscode . Uri ? [ item ] : item ) )
@@ -363,7 +374,7 @@ export class TestFileSystemDialog {
363
374
callback ?: ( dialog : TestFileSystemDialog ) => void
364
375
) : Window [ 'showSaveDialog' ] {
365
376
return async ( options ?: vscode . SaveDialogOptions ) => {
366
- const dialog = new TestFileSystemDialog ( [ ] , { type : 'save ' , ...options } )
377
+ const dialog = new TestFileSystemDialog ( [ ] , { type : 'Save ' , ...options } )
367
378
368
379
return new Promise < vscode . Uri | undefined > ( resolve => {
369
380
dialog . onDidAcceptItem ( item => resolve ( Array . isArray ( item ) ? item [ 0 ] : item ) )
0 commit comments