@@ -45,12 +45,21 @@ export async function activate(context: vscode.ExtensionContext) {
4545 traceInfo ( 'Authentication provider registered' )
4646
4747 context . subscriptions . push (
48- vscode . commands . registerCommand ( 'sqlmesh.signin' , signIn ( authProvider ) ) ,
48+ vscode . commands . registerCommand (
49+ 'sqlmesh.signin' ,
50+ signIn ( authProvider , async ( ) => {
51+ traceInfo ( 'Restarting LSP after sign-in' )
52+ await restart ( )
53+ } ) ,
54+ ) ,
4955 )
5056 context . subscriptions . push (
5157 vscode . commands . registerCommand (
5258 'sqlmesh.signinSpecifyFlow' ,
53- signInSpecifyFlow ( authProvider ) ,
59+ signInSpecifyFlow ( authProvider , async ( ) => {
60+ traceInfo ( 'Restarting LSP after sign-in' )
61+ await restart ( )
62+ } ) ,
5463 ) ,
5564 )
5665 context . subscriptions . push (
@@ -76,13 +85,6 @@ export async function activate(context: vscode.ExtensionContext) {
7685 ) ,
7786 )
7887
79- context . subscriptions . push (
80- vscode . commands . registerCommand (
81- 'sqlmesh.format' ,
82- format ( authProvider , lspClient ) ,
83- ) ,
84- )
85-
8688 // Register the webview
8789 const lineagePanel = new LineagePanel ( context . extensionUri , lspClient )
8890 context . subscriptions . push (
@@ -118,14 +120,35 @@ export async function activate(context: vscode.ExtensionContext) {
118120 if ( isErr ( restartResult ) ) {
119121 return handleError (
120122 authProvider ,
123+ restart ,
121124 restartResult . error ,
122125 'LSP restart failed' ,
123126 )
124127 }
125128 context . subscriptions . push ( lspClient )
129+ } else {
130+ lspClient = new LSPClient ( )
131+ const result = await lspClient . start ( )
132+ if ( isErr ( result ) ) {
133+ return handleError (
134+ authProvider ,
135+ restart ,
136+ result . error ,
137+ 'Failed to start LSP' ,
138+ )
139+ } else {
140+ context . subscriptions . push ( lspClient )
141+ }
126142 }
127143 }
128144
145+ context . subscriptions . push (
146+ vscode . commands . registerCommand (
147+ 'sqlmesh.format' ,
148+ format ( authProvider , lspClient , restart ) ,
149+ ) ,
150+ )
151+
129152 context . subscriptions . push (
130153 onDidChangePythonInterpreter ( async ( ) => {
131154 await restart ( )
@@ -140,7 +163,12 @@ export async function activate(context: vscode.ExtensionContext) {
140163
141164 const result = await lspClient . start ( )
142165 if ( isErr ( result ) ) {
143- return handleError ( authProvider , result . error , 'Failed to start LSP' )
166+ return handleError (
167+ authProvider ,
168+ restart ,
169+ result . error ,
170+ 'Failed to start LSP' ,
171+ )
144172 } else {
145173 context . subscriptions . push ( lspClient )
146174 }
0 commit comments