@@ -92,6 +92,7 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
92
92
private profileWidget : ProfileWidget | undefined ;
93
93
94
94
private model : UserDataProfilesEditorModel | undefined ;
95
+ private templates : readonly IProfileTemplateInfo [ ] = [ ] ;
95
96
96
97
constructor (
97
98
group : IEditorGroup ,
@@ -207,7 +208,7 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
207
208
actions : {
208
209
getActions : ( ) => {
209
210
const actions : IAction [ ] = [ ] ;
210
- if ( this . model ?. templates . length ) {
211
+ if ( this . templates . length ) {
211
212
actions . push ( new SubmenuAction ( 'from.template' , localize ( 'from template' , "From Template" ) , this . getCreateFromTemplateActions ( ) ) ) ;
212
213
actions . push ( new Separator ( ) ) ;
213
214
}
@@ -225,15 +226,13 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
225
226
}
226
227
227
228
private getCreateFromTemplateActions ( ) : IAction [ ] {
228
- return this . model
229
- ? this . model . templates . map ( template =>
230
- new Action (
231
- `template:${ template . url } ` ,
232
- template . name ,
233
- undefined ,
234
- true ,
235
- ( ) => this . createNewProfile ( URI . parse ( template . url ) ) ) )
236
- : [ ] ;
229
+ return this . templates . map ( template =>
230
+ new Action (
231
+ `template:${ template . url } ` ,
232
+ template . name ,
233
+ undefined ,
234
+ true ,
235
+ ( ) => this . createNewProfile ( URI . parse ( template . url ) ) ) ) ;
237
236
}
238
237
239
238
private registerListeners ( ) : void {
@@ -343,9 +342,12 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
343
342
override async setInput ( input : UserDataProfilesEditorInput , options : IEditorOptions | undefined , context : IEditorOpenContext , token : CancellationToken ) : Promise < void > {
344
343
await super . setInput ( input , options , context , token ) ;
345
344
this . model = await input . resolve ( ) ;
346
- if ( this . profileWidget ) {
347
- this . profileWidget . templates = this . model . templates ;
348
- }
345
+ this . model . getTemplates ( ) . then ( templates => {
346
+ this . templates = templates ;
347
+ if ( this . profileWidget ) {
348
+ this . profileWidget . templates = templates ;
349
+ }
350
+ } ) ;
349
351
this . updateProfilesList ( ) ;
350
352
this . _register ( this . model . onDidChange ( element =>
351
353
this . updateProfilesList ( element ) ) ) ;
0 commit comments