This commit is contained in:
Jackson Kearl 2021-05-21 16:03:36 -07:00
parent cd8bf7ba53
commit 28767c88f0
No known key found for this signature in database
GPG key ID: DA09A59C409FC400
3 changed files with 30 additions and 1 deletions

View file

@ -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({

View file

@ -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; }

View file

@ -128,6 +128,8 @@ export interface IGettingStartedService {
progressByEvent(eventName: string): void;
progressStep(id: string): void;
deprogressStep(id: string): void;
installedExtensionsRegistered: Promise<void>;
}
export class GettingStartedService extends Disposable implements IGettingStartedService {
@ -162,6 +164,9 @@ export class GettingStartedService extends Disposable implements IGettingStarted
private trackedContextKeys = new Set<string>();
private triggerInstalledExtensionsRegistered!: () => void;
installedExtensionsRegistered: Promise<void>;
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<string>('workbench.welcomePage.experimental.extensionContributions') !== 'hide') {
this.commandService.executeCommand('workbench.action.openWalkthrough', sectionToOpen);
}