Skip to content

Commit 559f5be

Browse files
authored
Support walkthrough restore from empty workspace (microsoft#204218)
1 parent 843de2d commit 559f5be

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { Link } from 'vs/platform/opener/browser/link';
4444
import { IOpenerService } from 'vs/platform/opener/common/opener';
4545
import { IProductService } from 'vs/platform/product/common/productService';
4646
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
47-
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
47+
import { IStorageService, StorageScope, StorageTarget, WillSaveStateReason } from 'vs/platform/storage/common/storage';
4848
import { ITelemetryService, TelemetryLevel, firstSessionDateStorageKey } from 'vs/platform/telemetry/common/telemetry';
4949
import { getTelemetryLevel } from 'vs/platform/telemetry/common/telemetryUtils';
5050
import { defaultButtonStyles, defaultToggleStyles } from 'vs/platform/theme/browser/defaultStyles';
@@ -282,6 +282,27 @@ export class GettingStartedPage extends EditorPane {
282282
}
283283
this.updateCategoryProgress();
284284
}));
285+
286+
this._register(this.storageService.onWillSaveState((e) => {
287+
if (e.reason !== WillSaveStateReason.SHUTDOWN) {
288+
return;
289+
}
290+
291+
if (this.workspaceContextService.getWorkspace().folders.length !== 0) {
292+
return;
293+
}
294+
295+
if (!this.editorInput || !this.currentWalkthrough || !this.editorInput.selectedCategory || !this.editorInput.selectedStep) {
296+
return;
297+
}
298+
299+
// Save the state of the walkthrough so we can restore it on reload
300+
const restoreData: RestoreWalkthroughsConfigurationValue = { folder: UNKNOWN_EMPTY_WINDOW_WORKSPACE.id, category: this.editorInput.selectedCategory, step: this.editorInput.selectedStep };
301+
this.storageService.store(
302+
restoreWalkthroughsConfigurationKey,
303+
JSON.stringify(restoreData),
304+
StorageScope.PROFILE, StorageTarget.MACHINE);
305+
}));
285306
}
286307

287308
// remove when 'workbench.welcomePage.preferReducedMotion' deprecated

0 commit comments

Comments
 (0)