@@ -16,10 +16,7 @@ export class GitEditSessionIdentityProvider implements vscode.EditSessionIdentit
1616 this . providerRegistration = vscode . workspace . registerEditSessionIdentityProvider ( 'file' , this ) ;
1717
1818 vscode . workspace . onWillCreateEditSessionIdentity ( ( e ) => {
19- const publishBeforeContinueOn = vscode . workspace . getConfiguration ( 'git' ) . get < 'never' | 'always' | 'prompt' > ( 'publishBeforeContinueOn' , 'prompt' ) ;
20- if ( publishBeforeContinueOn !== 'never' ) {
21- e . waitUntil ( this . _onWillCreateEditSessionIdentity ( e . workspaceFolder , e . token , publishBeforeContinueOn ) ) ;
22- }
19+ e . waitUntil ( this . _onWillCreateEditSessionIdentity ( e . workspaceFolder ) ) ;
2320 } ) ;
2421 }
2522
@@ -67,12 +64,11 @@ export class GitEditSessionIdentityProvider implements vscode.EditSessionIdentit
6764 }
6865 }
6966
70- private async _onWillCreateEditSessionIdentity ( workspaceFolder : vscode . WorkspaceFolder , cancellationToken : vscode . CancellationToken , publishBeforeContinueOn : 'always' | 'prompt' ) : Promise < void > {
71- const cancellationPromise = createCancellationPromise ( cancellationToken ) ;
72- await Promise . race ( [ this . _doPublish ( workspaceFolder , publishBeforeContinueOn ) , cancellationPromise ] ) ;
67+ private async _onWillCreateEditSessionIdentity ( workspaceFolder : vscode . WorkspaceFolder ) : Promise < void > {
68+ await this . _doPublish ( workspaceFolder ) ;
7369 }
7470
75- private async _doPublish ( workspaceFolder : vscode . WorkspaceFolder , publishBeforeContinueOn : 'always' | 'prompt' ) {
71+ private async _doPublish ( workspaceFolder : vscode . WorkspaceFolder ) {
7672 await this . model . openRepository ( path . dirname ( workspaceFolder . uri . fsPath ) ) ;
7773
7874 const repository = this . model . getRepository ( workspaceFolder . uri ) ;
@@ -86,31 +82,17 @@ export class GitEditSessionIdentityProvider implements vscode.EditSessionIdentit
8682 // ensure that it is published before Continue On is invoked
8783 if ( ! repository . HEAD ?. upstream && repository . HEAD ?. type === RefType . Head ) {
8884
89- if ( publishBeforeContinueOn === 'prompt' ) {
90- const always = vscode . l10n . t ( 'Always' ) ;
91- const never = vscode . l10n . t ( 'Never' ) ;
92- const selection = await vscode . window . showInformationMessage (
93- vscode . l10n . t ( 'The current branch is not published to the remote. Would you like to publish it to access your changes elsewhere?' ) ,
94- { modal : true } ,
95- ...[ always , never ]
96- ) ;
97- switch ( selection ) {
98- case always :
99- vscode . workspace . getConfiguration ( 'git' ) . update ( 'publishBeforeContinueOn' , 'always' ) ;
100- break ;
101- case never :
102- vscode . workspace . getConfiguration ( 'git' ) . update ( 'publishBeforeContinueOn' , 'never' ) ;
103- default :
104- return ;
105- }
85+ const publishBranch = vscode . l10n . t ( 'Publish Branch' ) ;
86+ const selection = await vscode . window . showInformationMessage (
87+ vscode . l10n . t ( 'The current branch is not published to the remote. Would you like to publish it to access your changes elsewhere?' ) ,
88+ { modal : true } ,
89+ publishBranch
90+ ) ;
91+ if ( selection !== publishBranch ) {
92+ throw new vscode . CancellationError ( ) ;
10693 }
10794
108- await vscode . window . withProgress ( {
109- location : vscode . ProgressLocation . Notification ,
110- title : vscode . l10n . t ( 'Publishing branch...' )
111- } , async ( ) => {
112- await vscode . commands . executeCommand ( 'git.publish' ) ;
113- } ) ;
95+ await vscode . commands . executeCommand ( 'git.publish' ) ;
11496 }
11597 }
11698}
@@ -128,14 +110,3 @@ function normalizeEditSessionIdentity(identity: string) {
128110 sha
129111 } ;
130112}
131-
132- function createCancellationPromise ( cancellationToken : vscode . CancellationToken ) {
133- return new Promise ( ( resolve , _ ) => {
134- if ( cancellationToken . isCancellationRequested ) {
135- resolve ( undefined ) ;
136- }
137- cancellationToken . onCancellationRequested ( ( ) => {
138- resolve ( undefined ) ;
139- } ) ;
140- } ) ;
141- }
0 commit comments