diff --git a/vscode-extension/src/aiConfigEditor.ts b/vscode-extension/src/aiConfigEditor.ts index b571776d0..61f08a969 100644 --- a/vscode-extension/src/aiConfigEditor.ts +++ b/vscode-extension/src/aiConfigEditor.ts @@ -103,40 +103,42 @@ export class AIConfigEditorProvider implements vscode.CustomTextEditorProvider { updateWebview(); // Do not start the server until we ensure the Python setup is ready - await initializePythonFlow(this.context, this.extensionOutputChannel); - - // Start the AIConfig editor server process. Don't await at the top level here since that blocks the - // webview render (which happens only when resolveCustomTextEditor returns) - this.startEditorServer(document).then(async (startedServer) => { - editorServer = startedServer; - - this.aiconfigEditorManager.addEditor( - new AIConfigEditorState( - document, - webviewPanel, - startedServer, - this.aiconfigEditorManager - ) - ); + initializePythonFlow(this.context, this.extensionOutputChannel).then( + async () => { + // Start the AIConfig editor server process. Don't await at the top level here since that blocks the + // webview render (which happens only when resolveCustomTextEditor returns) + this.startEditorServer(document).then(async (startedServer) => { + editorServer = startedServer; + + this.aiconfigEditorManager.addEditor( + new AIConfigEditorState( + document, + webviewPanel, + startedServer, + this.aiconfigEditorManager + ) + ); - // Wait for server ready - await waitUntilServerReady(startedServer.url); + // Wait for server ready + await waitUntilServerReady(startedServer.url); - // Now set up the server with the latest document content - await this.startServerWithRetry( - startedServer.url, - document, - webviewPanel - ); + // Now set up the server with the latest document content + await this.startServerWithRetry( + startedServer.url, + document, + webviewPanel + ); - // Inform the webview of the server URL - if (!isWebviewDisposed) { - webviewPanel.webview.postMessage({ - type: "set_server_url", - url: startedServer.url, + // Inform the webview of the server URL + if (!isWebviewDisposed) { + webviewPanel.webview.postMessage({ + type: "set_server_url", + url: startedServer.url, + }); + } }); } - }); + ); // Hook up event handlers so that we can synchronize the webview with the text document. //