@@ -76,8 +76,14 @@ export const askToSelectPrompt = async (
76
76
) : Promise < void > => {
77
77
const { promptFiles, resource, quickInputService, labelService } = options ;
78
78
79
- const fileOptions = promptFiles . map ( ( { uri } ) => {
80
- return createPickItem ( uri , labelService ) ;
79
+ // a sanity check - this function must be used only if there are prompt files to show
80
+ assert (
81
+ promptFiles . length > 0 ,
82
+ 'Prompt files list must not be empty.' ,
83
+ ) ;
84
+
85
+ const fileOptions = promptFiles . map ( ( promptFile ) => {
86
+ return createPickItem ( promptFile , labelService ) ;
81
87
} ) ;
82
88
83
89
/**
@@ -98,7 +104,12 @@ export const askToSelectPrompt = async (
98
104
// the currently active prompt file is always available in the selection dialog,
99
105
// even if it is not included in the prompts list otherwise(from location setting)
100
106
if ( ! activeItem ) {
101
- activeItem = createPickItem ( resource , labelService ) ;
107
+ activeItem = createPickItem ( {
108
+ uri : resource ,
109
+ // "user" prompts are always registered in the prompts list, hence it
110
+ // should be safe to assume that `resource` is not "user" prompt here
111
+ type : 'local' ,
112
+ } , labelService ) ;
102
113
fileOptions . push ( activeItem ) ;
103
114
}
104
115
@@ -191,16 +202,30 @@ export const askToSelectPrompt = async (
191
202
* Creates a quick pick item for a prompt.
192
203
*/
193
204
const createPickItem = (
194
- uri : URI ,
205
+ promptFile : IPromptPath ,
195
206
labelService : ILabelService ,
196
207
) : WithUriValue < IQuickPickItem > => {
208
+ const { uri, type } = promptFile ;
197
209
const fileWithoutExtension = getCleanPromptName ( uri ) ;
198
210
211
+ // if a "user" prompt, don't show its filesystem path in
212
+ // the user interface, but do that for all the "local" ones
213
+ const description = ( type === 'user' )
214
+ ? localize (
215
+ 'user-prompt.capitalized' ,
216
+ 'User prompt' ,
217
+ )
218
+ : labelService . getUriLabel ( dirname ( uri ) , { relative : true } ) ;
219
+
220
+ const tooltip = ( type === 'user' )
221
+ ? description
222
+ : uri . fsPath ;
223
+
199
224
return {
200
225
type : 'item' ,
201
226
label : fileWithoutExtension ,
202
- description : labelService . getUriLabel ( dirname ( uri ) , { relative : true } ) ,
203
- tooltip : uri . fsPath ,
227
+ description,
228
+ tooltip,
204
229
value : uri ,
205
230
id : uri . toString ( ) ,
206
231
} ;
0 commit comments