@@ -47,7 +47,7 @@ import { EditSessionsDataViews } from 'vs/workbench/contrib/editSessions/browser
47
47
import { EditSessionsFileSystemProvider } from 'vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider' ;
48
48
import { isNative } from 'vs/base/common/platform' ;
49
49
import { WorkspaceFolderCountContext } from 'vs/workbench/common/contextkeys' ;
50
- import { CancellationTokenSource } from 'vs/base/common/cancellation' ;
50
+ import { CancellationToken , CancellationTokenSource } from 'vs/base/common/cancellation' ;
51
51
import { equals } from 'vs/base/common/objects' ;
52
52
import { EditSessionIdentityMatch , IEditSessionIdentityService } from 'vs/platform/workspace/common/editSessions' ;
53
53
import { ThemeIcon } from 'vs/platform/theme/common/themeService' ;
@@ -209,11 +209,15 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
209
209
210
210
private async autoStoreEditSession ( ) {
211
211
if ( this . configurationService . getValue ( 'workbench.experimental.editSessions.autoStore' ) === 'onShutdown' ) {
212
+ const cancellationTokenSource = new CancellationTokenSource ( ) ;
212
213
await this . progressService . withProgress ( {
213
214
location : ProgressLocation . Window ,
214
215
type : 'syncing' ,
215
216
title : localize ( 'store working changes' , 'Storing working changes...' )
216
- } , async ( ) => this . storeEditSession ( false ) ) ;
217
+ } , async ( ) => this . storeEditSession ( false , cancellationTokenSource . token ) , ( ) => {
218
+ cancellationTokenSource . cancel ( ) ;
219
+ cancellationTokenSource . dispose ( ) ;
220
+ } ) ;
217
221
}
218
222
}
219
223
@@ -308,11 +312,16 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
308
312
// Run the store action to get back a ref
309
313
let ref : string | undefined ;
310
314
if ( shouldStoreEditSession ) {
315
+ const cancellationTokenSource = new CancellationTokenSource ( ) ;
311
316
ref = await that . progressService . withProgress ( {
312
317
location : ProgressLocation . Notification ,
318
+ cancellable : true ,
313
319
type : 'syncing' ,
314
320
title : localize ( 'store your working changes' , 'Storing your working changes...' )
315
- } , async ( ) => that . storeEditSession ( false ) ) ;
321
+ } , async ( ) => that . storeEditSession ( false , cancellationTokenSource . token ) , ( ) => {
322
+ cancellationTokenSource . cancel ( ) ;
323
+ cancellationTokenSource . dispose ( ) ;
324
+ } ) ;
316
325
}
317
326
318
327
// Append the ref to the URI
@@ -380,6 +389,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
380
389
}
381
390
382
391
async run ( accessor : ServicesAccessor ) : Promise < void > {
392
+ const cancellationTokenSource = new CancellationTokenSource ( ) ;
383
393
await that . progressService . withProgress ( {
384
394
location : ProgressLocation . Notification ,
385
395
title : localize ( 'storing working changes' , 'Storing working changes...' )
@@ -390,7 +400,10 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
390
400
} ;
391
401
that . telemetryService . publicLog2 < StoreEvent , StoreClassification > ( 'editSessions.store' ) ;
392
402
393
- await that . storeEditSession ( true ) ;
403
+ await that . storeEditSession ( true , cancellationTokenSource . token ) ;
404
+ } , ( ) => {
405
+ cancellationTokenSource . cancel ( ) ;
406
+ cancellationTokenSource . dispose ( ) ;
394
407
} ) ;
395
408
}
396
409
} ) ) ;
@@ -484,7 +497,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
484
497
if ( folder . canonicalIdentity ) {
485
498
// Look for an edit session identifier that we can use
486
499
for ( const f of workspaceFolders ) {
487
- const identity = await this . editSessionIdentityService . getEditSessionIdentifier ( f , cancellationTokenSource ) ;
500
+ const identity = await this . editSessionIdentityService . getEditSessionIdentifier ( f , cancellationTokenSource . token ) ;
488
501
this . logService . info ( `Matching identity ${ identity } against edit session folder identity ${ folder . canonicalIdentity } ...` ) ;
489
502
490
503
if ( equals ( identity , folder . canonicalIdentity ) ) {
@@ -493,7 +506,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
493
506
}
494
507
495
508
if ( identity !== undefined ) {
496
- const match = await this . editSessionIdentityService . provideEditSessionIdentityMatch ( f , identity , folder . canonicalIdentity , cancellationTokenSource ) ;
509
+ const match = await this . editSessionIdentityService . provideEditSessionIdentityMatch ( f , identity , folder . canonicalIdentity , cancellationTokenSource . token ) ;
497
510
if ( match === EditSessionIdentityMatch . Complete ) {
498
511
folderRoot = f ;
499
512
break ;
@@ -566,7 +579,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
566
579
}
567
580
}
568
581
569
- async storeEditSession ( fromStoreCommand : boolean ) : Promise < string | undefined > {
582
+ async storeEditSession ( fromStoreCommand : boolean , cancellationToken : CancellationToken ) : Promise < string | undefined > {
570
583
const folders : Folder [ ] = [ ] ;
571
584
let hasEdits = false ;
572
585
@@ -612,7 +625,10 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
612
625
}
613
626
}
614
627
615
- const canonicalIdentity = workspaceFolder ? await this . editSessionIdentityService . getEditSessionIdentifier ( workspaceFolder , new CancellationTokenSource ( ) ) : undefined ;
628
+ let canonicalIdentity = undefined ;
629
+ if ( workspaceFolder !== null && workspaceFolder !== undefined ) {
630
+ canonicalIdentity = await this . editSessionIdentityService . getEditSessionIdentifier ( workspaceFolder , cancellationToken ) ;
631
+ }
616
632
617
633
folders . push ( { workingChanges, name : name ?? '' , canonicalIdentity : canonicalIdentity ?? undefined } ) ;
618
634
}
0 commit comments