@@ -48,9 +48,7 @@ export function initialize(): Promise<void> {
48
48
...getConfigurationServiceOverride ( ) ,
49
49
...getEditorServiceOverride (
50
50
( model , _input , _side_by_side ) => {
51
- return Promise . resolve (
52
- EDITOR_WIDGET ! . open_model_ref ( model ) ,
53
- ) ;
51
+ return EDITOR_WIDGET ! . open_model_ref ( model ) ;
54
52
} ,
55
53
) ,
56
54
...getKeybindingsServiceOverride ( ) ,
@@ -390,12 +388,7 @@ export class EditorWidget extends Widget {
390
388
391
389
this . clear_editors ( ) ;
392
390
393
- this . open_default_content ( ) . then ( ( uri ) => {
394
- this . #client?. sendRequest ( "workspace/executeCommand" , {
395
- command : "slint/showPreview" ,
396
- arguments : [ uri ?. toString ( ) ?? "" , "" ] ,
397
- } ) ;
398
- } ) ;
391
+ this . open_default_content ( ) ;
399
392
}
400
393
401
394
private async open_default_content ( ) {
@@ -451,9 +444,9 @@ export class EditorWidget extends Widget {
451
444
. then ( ( model_ref ) => this . open_model_ref ( model_ref ) ) ;
452
445
}
453
446
454
- public open_model_ref (
447
+ public async open_model_ref (
455
448
model_ref : IReference < ITextEditorModel > ,
456
- ) : IStandaloneCodeEditor {
449
+ ) : Promise < IStandaloneCodeEditor > {
457
450
const pane = new EditorPaneWidget ( model_ref ) ;
458
451
this . #tab_map. set (
459
452
model_ref . object . textEditorModel ?. uri ??
@@ -462,7 +455,17 @@ export class EditorWidget extends Widget {
462
455
) ;
463
456
this . #tab_panel! . addWidget ( pane ) ;
464
457
465
- return pane . editor ;
458
+ if ( this . #tab_map. size === 1 ) {
459
+ await this . #client?. sendRequest ( "workspace/executeCommand" , {
460
+ command : "slint/showPreview" ,
461
+ arguments : [
462
+ model_ref . object . textEditorModel ?. uri . toString ( ) ?? "" ,
463
+ "" ,
464
+ ] ,
465
+ } ) ;
466
+ }
467
+
468
+ return Promise . resolve ( pane . editor ) ;
466
469
}
467
470
468
471
public async map_url ( url_ : string ) : Promise < string | undefined > {
0 commit comments