@@ -144,22 +144,33 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
144
144
} ;
145
145
this . telemetryService . publicLog2 < ResumeEvent , ResumeClassification > ( 'editSessions.continue.resume' ) ;
146
146
147
+ const shouldAutoResumeOnReload = this . configurationService . getValue ( 'workbench.editSessions.autoResume' ) === 'onReload' ;
148
+
147
149
if ( this . environmentService . editSessionId !== undefined ) {
148
150
this . logService . info ( `Resuming edit session, reason: found editSessionId ${ this . environmentService . editSessionId } in environment service...` ) ;
149
151
await this . resumeEditSession ( this . environmentService . editSessionId ) . finally ( ( ) => this . environmentService . editSessionId = undefined ) ;
150
- } else if (
151
- this . configurationService . getValue ( 'workbench.editSessions.autoResume' ) === 'onReload' &&
152
- this . editSessionsStorageService . isSignedIn
153
- ) {
152
+ } else if ( shouldAutoResumeOnReload && this . editSessionsStorageService . isSignedIn ) {
154
153
this . logService . info ( 'Resuming edit session, reason: edit sessions enabled...' ) ;
155
154
// Attempt to resume edit session based on edit workspace identifier
156
155
// Note: at this point if the user is not signed into edit sessions,
157
156
// we don't want them to be prompted to sign in and should just return early
158
157
await this . resumeEditSession ( undefined , true ) ;
159
- } else {
158
+ } else if ( shouldAutoResumeOnReload ) {
160
159
// The application has previously launched via a protocol URL Continue On flow
161
160
const hasApplicationLaunchedFromContinueOnFlow = this . storageService . getBoolean ( EditSessionsContribution . APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY , StorageScope . APPLICATION , false ) ;
162
161
162
+ const handlePendingEditSessions = ( ) => {
163
+ // display a badge in the accounts menu but do not prompt the user to sign in again
164
+ this . updateAccountsMenuBadge ( ) ;
165
+ // attempt a resume if we are in a pending state and the user just signed in
166
+ const disposable = this . editSessionsStorageService . onDidSignIn ( async ( ) => {
167
+ disposable . dispose ( ) ;
168
+ this . resumeEditSession ( undefined , true ) ;
169
+ this . storageService . remove ( EditSessionsContribution . APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY , StorageScope . APPLICATION ) ;
170
+ this . environmentService . continueOn = undefined ;
171
+ } ) ;
172
+ } ;
173
+
163
174
if ( ( this . environmentService . continueOn !== undefined ) &&
164
175
! this . editSessionsStorageService . isSignedIn &&
165
176
// and user has not yet been prompted to sign in on this machine
@@ -170,17 +181,14 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
170
181
if ( this . editSessionsStorageService . isSignedIn ) {
171
182
await this . resumeEditSession ( undefined , true ) ;
172
183
} else {
173
- this . updateAccountsMenuBadge ( ) ;
184
+ handlePendingEditSessions ( ) ;
174
185
}
175
186
// store the fact that we prompted the user
176
187
} else if ( ! this . editSessionsStorageService . isSignedIn &&
177
188
// and user has been prompted to sign in on this machine
178
189
hasApplicationLaunchedFromContinueOnFlow === true
179
190
) {
180
- // display a badge in the accounts menu but do not prompt the user to sign in again
181
- this . updateAccountsMenuBadge ( ) ;
182
- // attempt a resume if we are in a pending state and the user just signed in
183
- this . _register ( this . editSessionsStorageService . onDidSignIn ( async ( ) => this . resumeEditSession ( undefined , true ) ) ) ;
191
+ handlePendingEditSessions ( ) ;
184
192
}
185
193
}
186
194
0 commit comments