diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts index b3d4638f57a..70452c9d49d 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts @@ -25,6 +25,7 @@ import product from 'vs/platform/product/common/product'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { EditorOverride } from 'vs/platform/editor/common/editor'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { CommandsRegistry } from 'vs/platform/commands/common/commands'; export * as icons from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedIcons'; @@ -122,6 +123,19 @@ registerAction2(class extends Action2 { } }); +CommandsRegistry.registerCommand({ + id: 'walkthroughs.selectStep', + handler: (accessor, stepID: string) => { + const editorService = accessor.get(IEditorService); + const editorPane = editorService.activeEditorPane; + if (editorPane instanceof GettingStartedPage) { + editorPane.selectStepLoose(stepID); + } else { + console.error('Cannot run walkthroughs.selectStep outside of walkthrough context'); + } + } +}); + registerAction2(class extends Action2 { constructor() { super({ diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.ts b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.ts index 11fec69efca..9f5cd95c490 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.ts @@ -234,7 +234,8 @@ export class GettingStartedPage extends EditorPane { } async makeCategoryVisibleWhenAvailable(categoryID: string) { - await this.extensionService.whenInstalledExtensionsRegistered(); + await this.gettingStartedService.installedExtensionsRegistered; + this.gettingStartedCategories = this.gettingStartedService.getCategories(); const ourCategory = this.gettingStartedCategories.find(c => c.id === categoryID); if (!ourCategory) { @@ -444,6 +445,11 @@ export class GettingStartedPage extends EditorPane { } } + async selectStepLoose(id: string) { + const toSelect = this.editorInput.selectedCategory + '#' + id; + this.selectStep(toSelect); + } + private async selectStep(id: string | undefined, delayFocus = true, forceRebuild = false) { if (id && this.editorInput.selectedStep === id && !forceRebuild) { return; } diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts index 225fde1310c..16eac49227e 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts @@ -128,6 +128,8 @@ export interface IGettingStartedService { progressByEvent(eventName: string): void; progressStep(id: string): void; deprogressStep(id: string): void; + + installedExtensionsRegistered: Promise; } export class GettingStartedService extends Disposable implements IGettingStartedService { @@ -162,6 +164,9 @@ export class GettingStartedService extends Disposable implements IGettingStarted private trackedContextKeys = new Set(); + private triggerInstalledExtensionsRegistered!: () => void; + installedExtensionsRegistered: Promise; + constructor( @IStorageService private readonly storageService: IStorageService, @ICommandService private readonly commandService: ICommandService, @@ -207,6 +212,8 @@ export class GettingStartedService extends Disposable implements IGettingStarted if (userDataAutoSyncEnablementService.isEnabled()) { this.progressByEvent('onEvent:sync-enabled'); } })); + this.installedExtensionsRegistered = new Promise(r => this.triggerInstalledExtensionsRegistered = r); + startEntries.forEach(async (entry, index) => { this.getCategoryOverrides(entry); this.registerStartEntry({ @@ -418,6 +425,8 @@ export class GettingStartedService extends Disposable implements IGettingStarted this.registerWalkthrough(walkthoughDescriptior, steps); })); + this.triggerInstalledExtensionsRegistered(); + if (sectionToOpen && this.configurationService.getValue('workbench.welcomePage.experimental.extensionContributions') !== 'hide') { this.commandService.executeCommand('workbench.action.openWalkthrough', sectionToOpen); }