diff options
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/activation/activate.ts | 19 | ||||
| -rw-r--r-- | extension/src/activation/environmentSetup.ts | 14 | ||||
| -rw-r--r-- | extension/src/continueIdeClient.ts | 7 | ||||
| -rw-r--r-- | extension/src/debugPanel.ts | 38 | 
4 files changed, 58 insertions, 20 deletions
diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index 8bdc7e21..a47d5e97 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -7,6 +7,9 @@ import {    startContinuePythonServer,  } from "./environmentSetup";  import fetch from "node-fetch"; +import { registerAllCodeLensProviders } from "../lang-server/codeLens"; +import { registerAllCommands } from "../commands"; +import registerQuickFixProvider from "../lang-server/codeActions";  const PACKAGE_JSON_RAW_GITHUB_URL =    "https://raw.githubusercontent.com/continuedev/continue/HEAD/extension/package.json"; @@ -46,6 +49,11 @@ export async function activateExtension(context: vscode.ExtensionContext) {      })      .catch((e) => console.log("Error checking for extension updates: ", e)); +  // Register commands and providers +  registerAllCodeLensProviders(context); +  registerAllCommands(context); +  registerQuickFixProvider(); +    // Start the server and display loader if taking > 2 seconds    const sessionIdPromise = (async () => {      await new Promise((resolve) => { @@ -78,6 +86,17 @@ export async function activateExtension(context: vscode.ExtensionContext) {                return Promise.resolve();              }            ); + +          vscode.window +            .showInformationMessage( +              "Click here to view the server logs, or use the 'continue.viewLogs' VS Code command.", +              "View Logs" +            ) +            .then((selection) => { +              if (selection === "View Logs") { +                vscode.commands.executeCommand("continue.viewLogs"); +              } +            });          }        }, 2000);      }); diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 44fb3b60..50a2783a 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -463,15 +463,13 @@ export async function startContinuePythonServer() {      const command = `cd "${serverPath()}" && ${activateCmd} && cd .. && ${pythonCmd} -m server.run_continue_server`; -    console.log("Starting Continue python server..."); -      return new Promise(async (resolve, reject) => { +      console.log("Starting Continue python server...");        try {          const child = spawn(command, {            shell: true,          });          child.stderr.on("data", (data: any) => { -          console.log(`stdout: ${data}`);            if (              data.includes("Uvicorn running on") || // Successfully started the server              data.includes("only one usage of each socket address") || // [windows] The server is already running (probably a simultaneously opened VS Code window) @@ -481,12 +479,22 @@ export async function startContinuePythonServer() {              resolve(null);            } else if (data.includes("ERROR") || data.includes("Traceback")) {              console.log("Error starting Continue python server: ", data); +          } else { +            console.log(`stdout: ${data}`);            }          });          child.on("error", (error: any) => {            console.log(`error: ${error.message}`);          }); +        child.on("close", (code: any) => { +          console.log(`child process exited with code ${code}`); +        }); + +        child.stdout.on("data", (data: any) => { +          console.log(`stdout: ${data}`); +        }); +          // Write the current version of vscode to a file called server_version.txt          fs.writeFileSync(serverVersionPath(), getExtensionVersion());        } catch (e) { diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 157b59cb..498cf9de 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -62,9 +62,11 @@ class IdeProtocolClient {        this._lastReloadTime = Math.min(2 * this._lastReloadTime, 5000);      };      messenger.onOpen(() => { +      console.log("IDE protocol websocket opened");        this._reconnectionTimeouts.forEach((to) => clearTimeout(to));      });      messenger.onClose(() => { +      console.log("IDE protocol websocket closed");        reconnect();      });      messenger.onError(() => { @@ -91,11 +93,6 @@ class IdeProtocolClient {      this._serverUrl = serverUrl;      this._newWebsocketMessenger(); -    // Register commands and providers -    registerAllCodeLensProviders(context); -    registerAllCommands(context); -    registerQuickFixProvider(); -      // Setup listeners for any file changes in open editors      // vscode.workspace.onDidChangeTextDocument((event) => {      //   if (this._makingEdit === 0) { diff --git a/extension/src/debugPanel.ts b/extension/src/debugPanel.ts index 3c4f8481..643563a2 100644 --- a/extension/src/debugPanel.ts +++ b/extension/src/debugPanel.ts @@ -17,17 +17,20 @@ class WebsocketConnection {    private _onMessage: (message: string) => void;    private _onOpen: () => void;    private _onClose: () => void; +  private _onError: (e: any) => void;    constructor(      url: string,      onMessage: (message: string) => void,      onOpen: () => void, -    onClose: () => void +    onClose: () => void, +    onError: (e: any) => void    ) {      this._ws = new WebSocket(url);      this._onMessage = onMessage;      this._onOpen = onOpen;      this._onClose = onClose; +    this._onError = onError;      this._ws.addEventListener("message", (event) => {        this._onMessage(event.data); @@ -38,6 +41,9 @@ class WebsocketConnection {      this._ws.addEventListener("open", () => {        this._onOpen();      }); +    this._ws.addEventListener("error", (e: any) => { +      this._onError(e); +    });    }    public send(message: string) { @@ -147,12 +153,20 @@ export function setupDebugPanel(            url,          });        }; +      const onError = (e: any) => { +        panel.webview.postMessage({ +          type: "websocketForwardingError", +          url, +          error: e, +        }); +      };        try {          const connection = new WebsocketConnection(            url,            onMessage,            onOpen, -          onClose +          onClose, +          onError          );          websocketConnections[url] = connection;          resolve(null); @@ -197,6 +211,15 @@ export function setupDebugPanel(          let url = data.url;          if (typeof websocketConnections[url] === "undefined") {            await connectWebsocket(url); +        } else { +          console.log( +            "Websocket connection requested by GUI already open at", +            url +          ); +          panel.webview.postMessage({ +            type: "websocketForwardingOpen", +            url, +          });          }          break;        } @@ -249,16 +272,7 @@ export function setupDebugPanel(              });            }          ); -        vscode.window -          .showInformationMessage( -            "Click here to view the server logs, or use the 'continue.viewLogs' VS Code command.", -            "View Logs" -          ) -          .then((selection) => { -            if (selection === "View Logs") { -              vscode.commands.executeCommand("continue.viewLogs"); -            } -          }); +          break;        }      }  | 
