@@ -11,23 +11,26 @@ function sanitizeRepositoryName(value: string): string {
1111 return value . trim ( ) . replace ( / [ ^ a - z 0 - 9 _ . ] / ig, '-' ) ;
1212}
1313
14- export function registerGlobalCommands ( context : vscode . ExtensionContext , gitAPI : GitAPI ) {
14+ export function registerCommands ( gitAPI : GitAPI ) : vscode . Disposable [ ] {
1515 async function publish ( ) : Promise < void > {
1616 if ( ! vscode . workspace . workspaceFolders ?. length ) {
1717 return ;
1818 }
1919
2020 const folder = vscode . workspace . workspaceFolders [ 0 ] ; // TODO
2121
22- const octokit = await getOctokit ( ) ;
23- const user = await octokit . users . getAuthenticated ( { } ) ;
24- const owner = user . data . login ;
25-
2622 const quickpick = vscode . window . createQuickPick < vscode . QuickPickItem & { repo ?: string , auth ?: 'https' | 'ssh' } > ( ) ;
2723 quickpick . ignoreFocusOut = true ;
2824
2925 quickpick . placeholder = 'Repository Name' ;
26+ quickpick . value = folder . name ;
3027 quickpick . show ( ) ;
28+ quickpick . busy = true ;
29+
30+ const octokit = await getOctokit ( ) ;
31+ const user = await octokit . users . getAuthenticated ( { } ) ;
32+ const owner = user . data . login ;
33+ quickpick . busy = false ;
3134
3235 let repo : string | undefined ;
3336
@@ -41,7 +44,6 @@ export function registerGlobalCommands(context: vscode.ExtensionContext, gitAPI:
4144 }
4245 } ;
4346
44- quickpick . value = folder . name ;
4547 onDidChangeValue ( ) ;
4648
4749 while ( true ) {
@@ -108,13 +110,17 @@ export function registerGlobalCommands(context: vscode.ExtensionContext, gitAPI:
108110 }
109111 }
110112
111- context . subscriptions . push ( vscode . commands . registerCommand ( 'github.publish' , async ( ) => {
113+ const disposables = [ ] ;
114+
115+ disposables . push ( vscode . commands . registerCommand ( 'github.publish' , async ( ) => {
112116 try {
113117 publish ( ) ;
114118 } catch ( err ) {
115119 vscode . window . showErrorMessage ( err . message ) ;
116120 }
117121 } ) ) ;
122+
123+ return disposables ;
118124}
119125
120126function getPick < T extends vscode . QuickPickItem > ( quickpick : vscode . QuickPick < T > ) : Promise < T | undefined > {
0 commit comments