File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 ApiResponseGetLineage ,
2424 ApiResponseGetModels ,
2525)
26+
27+ # Define the command constant
28+ EXTERNAL_MODEL_UPDATE_COLUMNS = "sqlmesh.external_model_update_columns"
29+
2630from sqlmesh .lsp .completions import get_sql_completions
2731from sqlmesh .lsp .context import (
2832 LSPContext ,
Original file line number Diff line number Diff line change @@ -131,8 +131,7 @@ export async function activate(context: vscode.ExtensionContext) {
131131 'LSP restart failed' ,
132132 )
133133 }
134- context . subscriptions . push ( lspClient )
135- context . subscriptions . push ( setupTestController ( lspClient ) )
134+ // Don't push to subscriptions again during restart - it's already there
136135 } else {
137136 lspClient = new LSPClient ( )
138137 const result = await lspClient . start ( invokedByUser )
Original file line number Diff line number Diff line change @@ -135,7 +135,24 @@ export class LSPClient implements Disposable {
135135 serverOptions ,
136136 clientOptions ,
137137 )
138- await this . client . start ( )
138+ try {
139+ await this . client . start ( )
140+ } catch ( error : any ) {
141+ // Ignore the specific error about command already being registered
142+ if (
143+ error ?. message ?. includes (
144+ "command 'sqlmesh.external_model_update_columns' already exists" ,
145+ )
146+ ) {
147+ traceInfo (
148+ 'Ignoring duplicate command registration error during restart' ,
149+ )
150+ // Continue normally - the client is still functional
151+ } else {
152+ // Re-throw other errors
153+ throw error
154+ }
155+ }
139156 return ok ( undefined )
140157 }
141158
@@ -149,6 +166,7 @@ export class LSPClient implements Disposable {
149166 public async stop ( stoppedByUser = false ) : Promise < void > {
150167 if ( this . client ) {
151168 await this . client . stop ( )
169+ await this . client . dispose ( )
152170 this . client = undefined
153171 // Reset supported methods state when the client stops
154172 this . supportedMethodsState = { type : 'not-fetched' }
You can’t perform that action at this time.
0 commit comments