diff --git a/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts b/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts index fa4c9f0966624..956c721efe963 100644 --- a/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts +++ b/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts @@ -56,6 +56,7 @@ import * as Constants from 'vs/workbench/contrib/logs/common/logConstants'; import { sha1Hex } from 'vs/base/browser/hash'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity'; +import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; registerSingleton(IEditSessionsLogService, EditSessionsLogService, InstantiationType.Delayed); registerSingleton(IEditSessionsStorageService, EditSessionsWorkbenchService, InstantiationType.Delayed); @@ -117,6 +118,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo @ILifecycleService private readonly lifecycleService: ILifecycleService, @IStorageService private readonly storageService: IStorageService, @IActivityService private readonly activityService: IActivityService, + @IEditorService private readonly editorService: IEditorService, ) { super(); @@ -295,11 +297,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo // Run the store action to get back a ref let ref: string | undefined; if (shouldStoreEditSession) { - ref = await that.progressService.withProgress({ - location: ProgressLocation.Notification, - type: 'syncing', - title: localize('store your edit session', 'Storing your edit session...') - }, async () => that.storeEditSession(false)); + ref = await that.storeEditSession(false); } let uri = workspaceUri ?? await that.pickContinueEditSessionDestination(); @@ -408,7 +406,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo } else if (ref !== undefined) { this.notificationService.warn(localize('no edit session content for ref', 'Could not resume edit session contents for ID {0}.', ref)); } - this.logService.info(ref !== undefined ? `Aborting resuming edit session as no edit session content is available to be applied from ref ${ref}.` : `Aborting resuming edit session as no edit session content is available to be applied`); + this.logService.info(`Aborting resuming edit session as no edit session content is available to be applied from ref ${ref}.`); return; } const editSession = data.editSession; @@ -562,6 +560,9 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo const folders: Folder[] = []; let hasEdits = false; + // Save all saveable editors before building edit session contents + await this.editorService.saveAll(); + for (const repository of this.scmService.repositories) { // Look through all resource groups and compute which files were added/modified/deleted const trackedUris = this.getChangedResources(repository); // A URI might appear in more than one resource group diff --git a/src/vs/workbench/contrib/editSessions/test/browser/editSessions.test.ts b/src/vs/workbench/contrib/editSessions/test/browser/editSessions.test.ts index 3bcd8b1d946c0..b4d87f01b5368 100644 --- a/src/vs/workbench/contrib/editSessions/test/browser/editSessions.test.ts +++ b/src/vs/workbench/contrib/editSessions/test/browser/editSessions.test.ts @@ -36,6 +36,7 @@ import { IViewDescriptorService } from 'vs/workbench/common/views'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; +import { IEditorService, ISaveAllEditorsOptions } from 'vs/workbench/services/editor/common/editorService'; const folderName = 'test-folder'; const folderUri = URI.file(`/${folderName}`); @@ -109,6 +110,9 @@ suite('Edit session sync', () => { instantiationService.stub(ITextModelService, new class extends mock() { override registerTextModelContentProvider = () => ({ dispose: () => { } }); }); + instantiationService.stub(IEditorService, new class extends mock() { + override saveAll = async (_options: ISaveAllEditorsOptions) => true; + }); editSessionsContribution = instantiationService.createInstance(EditSessionsContribution); });