@@ -27,12 +27,14 @@ import { GettingStartedDetailsRenderer } from 'vs/workbench/contrib/welcomeGetti
27
27
import { IConfigurationRegistry , Extensions as ConfigurationExtensions , ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry' ;
28
28
import { localize } from 'vs/nls' ;
29
29
import { applicationConfigurationNodeBase } from 'vs/workbench/common/configuration' ;
30
+ import { RunOnceScheduler } from 'vs/base/common/async' ;
30
31
31
32
const configurationKey = 'workbench.welcome.experimental.dialog' ;
32
33
33
34
class WelcomeDialogContribution extends Disposable implements IWorkbenchContribution {
34
35
35
36
private contextKeysToWatch = new Set < string > ( ) ;
37
+ private isRendered = false ;
36
38
37
39
constructor (
38
40
@IStorageService storageService : IStorageService ,
@@ -69,27 +71,41 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
69
71
this . contextKeysToWatch . add ( welcomeDialog . when ) ;
70
72
71
73
this . _register ( this . contextService . onDidChangeContext ( e => {
72
- if ( e . affectsSome ( this . contextKeysToWatch ) &&
73
- Array . from ( this . contextKeysToWatch ) . every ( value => this . contextService . contextMatchesRules ( ContextKeyExpr . deserialize ( value ) ) ) ) {
74
- const codeEditor = this . codeEditorService . getActiveCodeEditor ( ) ;
75
- if ( codeEditor ?. hasModel ( ) ) {
74
+ if ( e . affectsSome ( this . contextKeysToWatch ) && ! this . isRendered ) {
76
75
77
- const detailsRenderer = new GettingStartedDetailsRenderer ( fileService , notificationService , extensionService , languageService ) ;
76
+ if ( ! Array . from ( this . contextKeysToWatch ) . every ( value => this . contextService . contextMatchesRules ( ContextKeyExpr . deserialize ( value ) ) ) ) {
77
+ return ;
78
+ }
78
79
79
- const welcomeWidget = new WelcomeWidget (
80
- codeEditor ,
81
- instantiationService ,
82
- commandService ,
83
- telemetryService ,
84
- openerService ,
85
- webviewService ,
86
- detailsRenderer ) ;
80
+ const codeEditor = this . codeEditorService . getActiveCodeEditor ( ) ;
87
81
88
- welcomeWidget . render ( welcomeDialog . title ,
89
- welcomeDialog . message ,
90
- welcomeDialog . buttonText ,
91
- welcomeDialog . buttonCommand ,
92
- welcomeDialog . media ) ;
82
+ if ( codeEditor ?. hasModel ( ) ) {
83
+ const scheduler = new RunOnceScheduler ( ( ) => {
84
+ this . isRendered = true ;
85
+ const detailsRenderer = new GettingStartedDetailsRenderer ( fileService , notificationService , extensionService , languageService ) ;
86
+
87
+ const welcomeWidget = new WelcomeWidget (
88
+ codeEditor ,
89
+ instantiationService ,
90
+ commandService ,
91
+ telemetryService ,
92
+ openerService ,
93
+ webviewService ,
94
+ detailsRenderer ) ;
95
+
96
+ welcomeWidget . render ( welcomeDialog . title ,
97
+ welcomeDialog . message ,
98
+ welcomeDialog . buttonText ,
99
+ welcomeDialog . buttonCommand ,
100
+ welcomeDialog . media ) ;
101
+
102
+ } , 3000 ) ;
103
+
104
+ this . _register ( codeEditor . onDidChangeModelContent ( ( e ) => {
105
+ if ( ! this . isRendered ) {
106
+ scheduler . schedule ( ) ;
107
+ }
108
+ } ) ) ;
93
109
94
110
this . contextKeysToWatch . delete ( welcomeDialog . when ) ;
95
111
}
@@ -110,7 +126,7 @@ configurationRegistry.registerConfiguration({
110
126
type : 'boolean' ,
111
127
default : false ,
112
128
tags : [ 'experimental' ] ,
113
- description : localize ( 'workbench.welcome.dialog' , "When enabled, a welcome widget is shown in the edior " )
129
+ description : localize ( 'workbench.welcome.dialog' , "When enabled, a welcome widget is shown in the editor " )
114
130
}
115
131
}
116
132
} ) ;
0 commit comments