@@ -10,7 +10,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
10
10
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService' ;
11
11
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
12
12
import { Disposable } from 'vs/base/common/lifecycle' ;
13
- import { ContextKeyExpr , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
13
+ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
14
14
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
15
15
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
16
16
import { ICommandService } from 'vs/platform/commands/common/commands' ;
@@ -28,12 +28,12 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions, Configur
28
28
import { localize } from 'vs/nls' ;
29
29
import { applicationConfigurationNodeBase } from 'vs/workbench/common/configuration' ;
30
30
import { RunOnceScheduler } from 'vs/base/common/async' ;
31
+ import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
31
32
32
33
const configurationKey = 'workbench.welcome.experimental.dialog' ;
33
34
34
35
class WelcomeDialogContribution extends Disposable implements IWorkbenchContribution {
35
36
36
- private contextKeysToWatch = new Set < string > ( ) ;
37
37
private isRendered = false ;
38
38
39
39
constructor (
@@ -50,7 +50,8 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
50
50
@IFileService readonly fileService : IFileService ,
51
51
@INotificationService readonly notificationService : INotificationService ,
52
52
@IExtensionService readonly extensionService : IExtensionService ,
53
- @ILanguageService readonly languageService : LanguageService
53
+ @ILanguageService readonly languageService : LanguageService ,
54
+ @IEditorService readonly editorService : IEditorService
54
55
) {
55
56
super ( ) ;
56
57
@@ -68,46 +69,38 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
68
69
return ;
69
70
}
70
71
71
- this . contextKeysToWatch . add ( welcomeDialog . when ) ;
72
-
73
- this . _register ( this . contextService . onDidChangeContext ( e => {
74
- if ( e . affectsSome ( this . contextKeysToWatch ) && ! this . isRendered ) {
75
-
76
- if ( ! Array . from ( this . contextKeysToWatch ) . every ( value => this . contextService . contextMatchesRules ( ContextKeyExpr . deserialize ( value ) ) ) ) {
77
- return ;
78
- }
79
-
80
- const codeEditor = this . codeEditorService . getActiveCodeEditor ( ) ;
72
+ this . _register ( editorService . onDidActiveEditorChange ( ( ) => {
73
+ if ( ! this . isRendered ) {
81
74
75
+ const codeEditor = codeEditorService . getActiveCodeEditor ( ) ;
82
76
if ( codeEditor ?. hasModel ( ) ) {
83
77
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
-
78
+ if ( codeEditor === codeEditorService . getActiveCodeEditor ( ) ) {
79
+ this . isRendered = true ;
80
+ const detailsRenderer = new GettingStartedDetailsRenderer ( fileService , notificationService , extensionService , languageService ) ;
81
+
82
+ const welcomeWidget = new WelcomeWidget (
83
+ codeEditor ,
84
+ instantiationService ,
85
+ commandService ,
86
+ telemetryService ,
87
+ openerService ,
88
+ webviewService ,
89
+ detailsRenderer ) ;
90
+
91
+ welcomeWidget . render ( welcomeDialog . title ,
92
+ welcomeDialog . message ,
93
+ welcomeDialog . buttonText ,
94
+ welcomeDialog . buttonCommand ,
95
+ welcomeDialog . media ) ;
96
+ }
102
97
} , 3000 ) ;
103
98
104
99
this . _register ( codeEditor . onDidChangeModelContent ( ( e ) => {
105
100
if ( ! this . isRendered ) {
106
101
scheduler . schedule ( ) ;
107
102
}
108
103
} ) ) ;
109
-
110
- this . contextKeysToWatch . delete ( welcomeDialog . when ) ;
111
104
}
112
105
}
113
106
} ) ) ;
0 commit comments