Restore walkthroughs after OpenFolderAction from emtpy workspaces (#183468)

Restore walkthroughs after OpenFolderAction from emtpry workspaces
This commit is contained in:
Bhavya U 2023-05-25 17:31:28 -07:00 committed by GitHub
parent 56a0248733
commit 08b0de6fb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 4 deletions

View file

@ -28,7 +28,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ContextKeyExpr, ContextKeyExpression, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IRecentFolder, IRecentlyOpened, IRecentWorkspace, isRecentFolder, isRecentWorkspace, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceContextService, UNKNOWN_EMPTY_WINDOW_WORKSPACE } from 'vs/platform/workspace/common/workspace';
import { ILabelService, Verbosity } from 'vs/platform/label/common/label';
import { IWindowOpenable } from 'vs/platform/window/common/window';
import { splitName } from 'vs/base/common/labels';
@ -60,7 +60,7 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { getTelemetryLevel } from 'vs/platform/telemetry/common/telemetryUtils';
import { WorkbenchStateContext } from 'vs/workbench/common/contextkeys';
import { OpenFolderViaWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
import { OpenFolderAction, OpenFileFolderAction, OpenFolderViaWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
import { Toggle } from 'vs/base/browser/ui/toggle/toggle';
import { Codicon } from 'vs/base/common/codicons';
@ -1227,6 +1227,28 @@ export class GettingStartedPage extends EditorPane {
if (!Array.isArray(args)) {
args = [args];
}
// If a step is requesting the OpenFolder action to be executed in an empty workspace...
if ((commandURI.path === OpenFileFolderAction.ID.toString() ||
commandURI.path === OpenFolderAction.ID.toString()) &&
this.workspaceContextService.getWorkspace().folders.length === 0) {
const selectedStepIndex = this.currentWalkthrough?.steps.findIndex(step => step.id === this.editorInput.selectedStep);
// and there are a few more steps after this step which are yet to be completed...
if (selectedStepIndex !== undefined &&
selectedStepIndex > -1 &&
this.currentWalkthrough?.steps.slice(selectedStepIndex + 1).some(step => !step.done)) {
const restoreData: RestoreWalkthroughsConfigurationValue = { folder: UNKNOWN_EMPTY_WINDOW_WORKSPACE.id, category: this.editorInput.selectedCategory, step: this.editorInput.selectedStep };
// save state to restore after reload
this.storageService.store(
restoreWalkthroughsConfigurationKey,
JSON.stringify(restoreData),
StorageScope.PROFILE, StorageTarget.MACHINE);
}
}
this.commandService.executeCommand(commandURI.path, ...args).then(result => {
const toOpen: URI = result?.openFolder;
if (toOpen) {

View file

@ -10,7 +10,7 @@ import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceContextService, UNKNOWN_EMPTY_WINDOW_WORKSPACE, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
import { ILifecycleService, StartupKind } from 'vs/workbench/services/lifecycle/common/lifecycle';
@ -113,7 +113,7 @@ export class StartupPageContribution implements IWorkbenchContribution {
else {
const restoreData: RestoreWalkthroughsConfigurationValue = JSON.parse(toRestore);
const currentWorkspace = this.contextService.getWorkspace();
if (restoreData.folder === currentWorkspace.folders[0].uri.toString()) {
if (restoreData.folder === currentWorkspace.folders[0].uri.toString() || restoreData.folder === UNKNOWN_EMPTY_WINDOW_WORKSPACE.id) {
this.editorService.openEditor(
this.instantiationService.createInstance(
GettingStartedInput,