mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Restore walkthroughs after OpenFolderAction from emtpy workspaces (#183468)
Restore walkthroughs after OpenFolderAction from emtpry workspaces
This commit is contained in:
parent
56a0248733
commit
08b0de6fb3
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue