Skip to content

Commit

Permalink
[vscode] Fix Setting editorServer (#1314)
Browse files Browse the repository at this point in the history
# [vscode] Fix Setting editorServer

Realized when looking into restarting the server that the `editorServer`
global var was not being set properly (was null on dispose). The problem
was using the same name for the resolved started server. This fixes by
using a different name

## Testing:
- Ensure the editorServer value is right when disposing the webview
- Close webview and open again and ensure new server at port 8000
- Make changes to JSON for a config and toggle back to the editor
webview and see the changes reflected there
  • Loading branch information
rholinshead authored Feb 23, 2024
2 parents 47515a1 + 5bfde38 commit c361a24
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions vscode-extension/src/aiConfigEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,33 @@ export class AIConfigEditorProvider implements vscode.CustomTextEditorProvider {

// 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 (editorServer) => {
editorServer = editorServer;
this.startEditorServer(document).then(async (startedServer) => {
editorServer = startedServer;

this.aiconfigEditorManager.addEditor(
new AIConfigEditorState(
document,
webviewPanel,
editorServer,
startedServer,
this.aiconfigEditorManager
)
);

// Wait for server ready
await waitUntilServerReady(editorServer.url);
await waitUntilServerReady(startedServer.url);

// Now set up the server with the latest document content
await this.startServerWithRetry(editorServer.url, document, webviewPanel);
await this.startServerWithRetry(
startedServer.url,
document,
webviewPanel
);

// Inform the webview of the server URL
if (!isWebviewDisposed) {
webviewPanel.webview.postMessage({
type: "set_server_url",
url: editorServer.url,
url: startedServer.url,
});
}
});
Expand Down

0 comments on commit c361a24

Please sign in to comment.