@@ -7,7 +7,6 @@ import { localize } from '../../../../../../../../nls.js';
7
7
import { URI } from '../../../../../../../../base/common/uri.js' ;
8
8
import { assert } from '../../../../../../../../base/common/assert.js' ;
9
9
import { Codicon } from '../../../../../../../../base/common/codicons.js' ;
10
- import { WithUriValue } from '../../../../../../../../base/common/types.js' ;
11
10
import { ThemeIcon } from '../../../../../../../../base/common/themables.js' ;
12
11
import { IPromptPath , IPromptsService } from '../../../../../common/promptSyntax/service/types.js' ;
13
12
import { dirname , extUri , joinPath } from '../../../../../../../../base/common/resources.js' ;
@@ -177,6 +176,7 @@ export class PromptFilePickers {
177
176
async selectPromptFile ( options : ISelectOptions ) : Promise < ISelectPromptResult | undefined > {
178
177
const quickPick = this . _quickInputService . createQuickPick < IPromptPickerQuickPickItem > ( ) ;
179
178
quickPick . busy = true ;
179
+ quickPick . placeholder = localize ( 'searching' , 'Searching for files...' ) ;
180
180
try {
181
181
const fileOptions = await this . _createPromptPickItems ( options ) ;
182
182
const activeItem = options . resource && fileOptions . find ( f => extUri . isEqual ( f . value , options . resource ) ) ;
@@ -256,15 +256,15 @@ export class PromptFilePickers {
256
256
if ( options . optionDelete !== false ) {
257
257
buttons . push ( DELETE_BUTTON ) ;
258
258
}
259
- const promptFiles = await this . _promptsService . listPromptFiles ( PromptsType . prompt , CancellationToken . None ) ;
259
+ const promptFiles = await this . _promptsService . listPromptFiles ( options . type , CancellationToken . None ) ;
260
260
261
261
const fileOptions = promptFiles . map ( ( promptFile ) => {
262
262
return this . _createPromptPickItem ( promptFile , buttons ) ;
263
263
} ) ;
264
264
265
265
// if a resource is provided, create an `activeItem` for it to pre-select
266
266
// it in the UI, and sort the list so the active item appears at the top
267
- let activeItem : WithUriValue < IQuickPickItem > | undefined ;
267
+ let activeItem : IPromptPickerQuickPickItem | undefined ;
268
268
if ( options . resource ) {
269
269
activeItem = fileOptions . find ( ( file ) => {
270
270
return extUri . isEqual ( file . value , options . resource ) ;
@@ -318,7 +318,7 @@ export class PromptFilePickers {
318
318
}
319
319
}
320
320
321
- private _createPromptPickItem ( promptFile : IPromptPath , buttons : IQuickInputButton [ ] ) : WithUriValue < IQuickPickItem > {
321
+ private _createPromptPickItem ( promptFile : IPromptPath , buttons : IQuickInputButton [ ] ) : IPromptPickerQuickPickItem {
322
322
const { uri, storage } = promptFile ;
323
323
const fileWithoutExtension = getCleanPromptName ( uri ) ;
324
324
@@ -343,7 +343,7 @@ export class PromptFilePickers {
343
343
} ;
344
344
}
345
345
346
- private async _handleButtonClick ( quickPick : IQuickPick < WithUriValue < IQuickPickItem > > , context : IQuickPickItemButtonEvent < WithUriValue < IQuickPickItem > > , options : ISelectOptions ) : Promise < void > {
346
+ private async _handleButtonClick ( quickPick : IQuickPick < IPromptPickerQuickPickItem > , context : IQuickPickItemButtonEvent < IPromptPickerQuickPickItem > , options : ISelectOptions ) : Promise < void > {
347
347
const { item, button } = context ;
348
348
const { value, } = item ;
349
349
@@ -358,15 +358,16 @@ export class PromptFilePickers {
358
358
// don't close the main prompt selection dialog by the confirmation dialog
359
359
const previousIgnoreFocusOut = quickPick . ignoreFocusOut ;
360
360
quickPick . ignoreFocusOut = true ;
361
-
362
- const currentFolder = dirname ( value ) ;
363
- const newName = await this . _instaService . invokeFunction ( askForPromptFileName , options . type , currentFolder ) ;
364
- if ( newName ) {
365
- await this . _fileService . move ( value , joinPath ( currentFolder , newName ) ) ;
361
+ try {
362
+ const currentFolder = dirname ( value ) ;
363
+ const newName = await this . _instaService . invokeFunction ( askForPromptFileName , options . type , currentFolder ) ;
364
+ if ( newName ) {
365
+ await this . _fileService . move ( value , joinPath ( currentFolder , newName ) ) ;
366
+ }
367
+ } finally {
368
+ quickPick . ignoreFocusOut = previousIgnoreFocusOut ;
369
+ quickPick . items = await this . _createPromptPickItems ( options ) ;
366
370
}
367
-
368
- quickPick . ignoreFocusOut = previousIgnoreFocusOut ;
369
- quickPick . items = await this . _createPromptPickItems ( options ) ;
370
371
return ;
371
372
}
372
373
@@ -378,7 +379,7 @@ export class PromptFilePickers {
378
379
`Expected maximum one active item, got '${ quickPick . activeItems . length } '.` ,
379
380
) ;
380
381
381
- const activeItem : WithUriValue < IQuickPickItem > | undefined = quickPick . activeItems [ 0 ] ;
382
+ const activeItem : IPromptPickerQuickPickItem | undefined = quickPick . activeItems [ 0 ] ;
382
383
383
384
// sanity checks - prompt file exists and is not a folder
384
385
const info = await this . _fileService . stat ( value ) ;
@@ -433,7 +434,7 @@ export class PromptFilePickers {
433
434
// we set the previous item as new active, or the next item
434
435
// if removed prompt item was in the beginning of the list
435
436
const newActiveItemIndex = Math . max ( removedIndex - 1 , 0 ) ;
436
- const newActiveItem : WithUriValue < IQuickPickItem > | undefined = quickPick . items [ newActiveItemIndex ] ;
437
+ const newActiveItem : IPromptPickerQuickPickItem | undefined = quickPick . items [ newActiveItemIndex ] ;
437
438
438
439
quickPick . activeItems = newActiveItem ? [ newActiveItem ] : [ ] ;
439
440
}
0 commit comments