diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-18 14:02:03 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-18 14:02:03 -0700 |
commit | 53ac7b93f456b471eaa7f03e015e2d8c0ef393e5 (patch) | |
tree | 7abd90560bd9b237a1b3451256d7cbcbfe4673ac /extension/src/activation/activate.ts | |
parent | a7ab1918f8894c5e5f71e31a88a21680e6e1d2dc (diff) | |
download | sncontinue-53ac7b93f456b471eaa7f03e015e2d8c0ef393e5.tar.gz sncontinue-53ac7b93f456b471eaa7f03e015e2d8c0ef393e5.tar.bz2 sncontinue-53ac7b93f456b471eaa7f03e015e2d8c0ef393e5.zip |
error handle on invalid config file, don't immediately show loading message
Diffstat (limited to 'extension/src/activation/activate.ts')
-rw-r--r-- | extension/src/activation/activate.ts | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index 5c6ffa02..8ea08e89 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -36,22 +36,44 @@ export async function activateExtension(context: vscode.ExtensionContext) { }) .catch((e) => console.log("Error checking for extension updates: ", e)); - // Start the Python server - await new Promise((resolve, reject) => { - vscode.window.withProgress( - { - location: vscode.ProgressLocation.Notification, - title: - "Starting Continue Server... (it may take a minute to download Python packages)", - cancellable: false, - }, - async (progress, token) => { - await startContinuePythonServer(); - resolve(null); + // Wrap the server start logic in a new Promise + const serverStartPromise = new Promise((resolve, reject) => { + let serverStarted = false; + + // Start the server and set serverStarted to true when done + startContinuePythonServer().then(() => { + serverStarted = true; + resolve(null); + }); + + // Wait for 2 seconds + setTimeout(() => { + // If the server hasn't started after 2 seconds, show the notification + if (!serverStarted) { + vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: + "Starting Continue Server... (it may take a minute to download Python packages)", + cancellable: false, + }, + async (progress, token) => { + // Wait for the server to start + while (!serverStarted) { + await new Promise((innerResolve) => + setTimeout(innerResolve, 1000) + ); + } + return Promise.resolve(); + } + ); } - ); + }, 2000); }); + // Await the server start promise + await serverStartPromise; + // Register commands and providers sendTelemetryEvent(TelemetryEvent.ExtensionActivated); registerAllCodeLensProviders(context); |