diff --git a/src/vs/workbench/browser/web.api.ts b/src/vs/workbench/browser/web.api.ts index 9dbb9b2641d33..75b65fc7c301a 100644 --- a/src/vs/workbench/browser/web.api.ts +++ b/src/vs/workbench/browser/web.api.ts @@ -637,11 +637,6 @@ export interface IWelcomeDialog { */ message: string; - /** - * Context key expression to control the visibility of the welcome dialog. - */ - when: string; - /** * Media to include in the welcome dialog. */ diff --git a/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.ts b/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.ts index 1a00c018da5dd..eadcf7cdce83f 100644 --- a/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.ts +++ b/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.ts @@ -10,7 +10,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Disposable } from 'vs/base/common/lifecycle'; -import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ICommandService } from 'vs/platform/commands/common/commands'; @@ -28,12 +28,12 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions, Configur import { localize } from 'vs/nls'; import { applicationConfigurationNodeBase } from 'vs/workbench/common/configuration'; import { RunOnceScheduler } from 'vs/base/common/async'; +import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; const configurationKey = 'workbench.welcome.experimental.dialog'; class WelcomeDialogContribution extends Disposable implements IWorkbenchContribution { - private contextKeysToWatch = new Set(); private isRendered = false; constructor( @@ -50,7 +50,8 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu @IFileService readonly fileService: IFileService, @INotificationService readonly notificationService: INotificationService, @IExtensionService readonly extensionService: IExtensionService, - @ILanguageService readonly languageService: LanguageService + @ILanguageService readonly languageService: LanguageService, + @IEditorService readonly editorService: IEditorService ) { super(); @@ -68,37 +69,31 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu return; } - this.contextKeysToWatch.add(welcomeDialog.when); - - this._register(this.contextService.onDidChangeContext(e => { - if (e.affectsSome(this.contextKeysToWatch) && !this.isRendered) { - - if (!Array.from(this.contextKeysToWatch).every(value => this.contextService.contextMatchesRules(ContextKeyExpr.deserialize(value)))) { - return; - } - - const codeEditor = this.codeEditorService.getActiveCodeEditor(); + this._register(editorService.onDidActiveEditorChange(() => { + if (!this.isRendered) { + const codeEditor = codeEditorService.getActiveCodeEditor(); if (codeEditor?.hasModel()) { const scheduler = new RunOnceScheduler(() => { - this.isRendered = true; - const detailsRenderer = new GettingStartedDetailsRenderer(fileService, notificationService, extensionService, languageService); - - const welcomeWidget = new WelcomeWidget( - codeEditor, - instantiationService, - commandService, - telemetryService, - openerService, - webviewService, - detailsRenderer); - - welcomeWidget.render(welcomeDialog.title, - welcomeDialog.message, - welcomeDialog.buttonText, - welcomeDialog.buttonCommand, - welcomeDialog.media); - + if (codeEditor === codeEditorService.getActiveCodeEditor()) { + this.isRendered = true; + const detailsRenderer = new GettingStartedDetailsRenderer(fileService, notificationService, extensionService, languageService); + + const welcomeWidget = new WelcomeWidget( + codeEditor, + instantiationService, + commandService, + telemetryService, + openerService, + webviewService, + detailsRenderer); + + welcomeWidget.render(welcomeDialog.title, + welcomeDialog.message, + welcomeDialog.buttonText, + welcomeDialog.buttonCommand, + welcomeDialog.media); + } }, 3000); this._register(codeEditor.onDidChangeModelContent((e) => { @@ -106,8 +101,6 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu scheduler.schedule(); } })); - - this.contextKeysToWatch.delete(welcomeDialog.when); } } }));