Skip to content

Commit 08b0de6

Browse files
authored
Restore walkthroughs after OpenFolderAction from emtpy workspaces (microsoft#183468)
Restore walkthroughs after OpenFolderAction from emtpry workspaces
1 parent 56a0248 commit 08b0de6

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
2828
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
2929
import { ContextKeyExpr, ContextKeyExpression, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
3030
import { IRecentFolder, IRecentlyOpened, IRecentWorkspace, isRecentFolder, isRecentWorkspace, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
31-
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
31+
import { IWorkspaceContextService, UNKNOWN_EMPTY_WINDOW_WORKSPACE } from 'vs/platform/workspace/common/workspace';
3232
import { ILabelService, Verbosity } from 'vs/platform/label/common/label';
3333
import { IWindowOpenable } from 'vs/platform/window/common/window';
3434
import { splitName } from 'vs/base/common/labels';
@@ -60,7 +60,7 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
6060
import { KeyCode } from 'vs/base/common/keyCodes';
6161
import { getTelemetryLevel } from 'vs/platform/telemetry/common/telemetryUtils';
6262
import { WorkbenchStateContext } from 'vs/workbench/common/contextkeys';
63-
import { OpenFolderViaWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
63+
import { OpenFolderAction, OpenFileFolderAction, OpenFolderViaWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
6464
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
6565
import { Toggle } from 'vs/base/browser/ui/toggle/toggle';
6666
import { Codicon } from 'vs/base/common/codicons';
@@ -1227,6 +1227,28 @@ export class GettingStartedPage extends EditorPane {
12271227
if (!Array.isArray(args)) {
12281228
args = [args];
12291229
}
1230+
1231+
// If a step is requesting the OpenFolder action to be executed in an empty workspace...
1232+
if ((commandURI.path === OpenFileFolderAction.ID.toString() ||
1233+
commandURI.path === OpenFolderAction.ID.toString()) &&
1234+
this.workspaceContextService.getWorkspace().folders.length === 0) {
1235+
1236+
const selectedStepIndex = this.currentWalkthrough?.steps.findIndex(step => step.id === this.editorInput.selectedStep);
1237+
1238+
// and there are a few more steps after this step which are yet to be completed...
1239+
if (selectedStepIndex !== undefined &&
1240+
selectedStepIndex > -1 &&
1241+
this.currentWalkthrough?.steps.slice(selectedStepIndex + 1).some(step => !step.done)) {
1242+
const restoreData: RestoreWalkthroughsConfigurationValue = { folder: UNKNOWN_EMPTY_WINDOW_WORKSPACE.id, category: this.editorInput.selectedCategory, step: this.editorInput.selectedStep };
1243+
1244+
// save state to restore after reload
1245+
this.storageService.store(
1246+
restoreWalkthroughsConfigurationKey,
1247+
JSON.stringify(restoreData),
1248+
StorageScope.PROFILE, StorageTarget.MACHINE);
1249+
}
1250+
}
1251+
12301252
this.commandService.executeCommand(commandURI.path, ...args).then(result => {
12311253
const toOpen: URI = result?.openFolder;
12321254
if (toOpen) {

src/vs/workbench/contrib/welcomeGettingStarted/browser/startupPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1010
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1111
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1212
import { onUnexpectedError } from 'vs/base/common/errors';
13-
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
13+
import { IWorkspaceContextService, UNKNOWN_EMPTY_WINDOW_WORKSPACE, WorkbenchState } from 'vs/platform/workspace/common/workspace';
1414
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1515
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
1616
import { ILifecycleService, StartupKind } from 'vs/workbench/services/lifecycle/common/lifecycle';
@@ -113,7 +113,7 @@ export class StartupPageContribution implements IWorkbenchContribution {
113113
else {
114114
const restoreData: RestoreWalkthroughsConfigurationValue = JSON.parse(toRestore);
115115
const currentWorkspace = this.contextService.getWorkspace();
116-
if (restoreData.folder === currentWorkspace.folders[0].uri.toString()) {
116+
if (restoreData.folder === currentWorkspace.folders[0].uri.toString() || restoreData.folder === UNKNOWN_EMPTY_WINDOW_WORKSPACE.id) {
117117
this.editorService.openEditor(
118118
this.instantiationService.createInstance(
119119
GettingStartedInput,

0 commit comments

Comments
 (0)