diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-09-01 14:08:30 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-09-01 14:08:30 -0700 | 
| commit | 631f7498190af1403c44f0bfdc93032a965df3ea (patch) | |
| tree | fafa6ddf7d9d08d314093e798b3cc370332a086c /extension/src | |
| parent | e6d4e5f60bcf855401d09a2649a516b5932cc53a (diff) | |
| parent | 07f1a9a4dbbca57c14957eb21ef356adbf803bff (diff) | |
| download | sncontinue-631f7498190af1403c44f0bfdc93032a965df3ea.tar.gz sncontinue-631f7498190af1403c44f0bfdc93032a965df3ea.tar.bz2 sncontinue-631f7498190af1403c44f0bfdc93032a965df3ea.zip | |
Merge branch 'main' of https://github.com/continuedev/continue
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/activation/environmentSetup.ts | 35 | ||||
| -rw-r--r-- | extension/src/continueIdeClient.ts | 89 | 
2 files changed, 68 insertions, 56 deletions
| diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 7ca87768..3aa536d0 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -74,6 +74,14 @@ function serverVersionPath(): string {    return path.join(serverPath(), "server_version.txt");  } +function serverBinaryPath(): string { +  return path.join( +    serverPath(), +    "exe", +    `run${os.platform() === "win32" ? ".exe" : ""}` +  ); +} +  export function getExtensionVersion() {    const extension = vscode.extensions.getExtension("continue.continue");    return extension?.packageJSON.version || ""; @@ -105,14 +113,7 @@ async function checkOrKillRunningServer(serverUrl: string): Promise<boolean> {          // Try again, on Windows. This time with taskkill          if (os.platform() === "win32") {            try { -            const exePath = path.join( -              getExtensionUri().fsPath, -              "server", -              "exe", -              "run.exe" -            ); - -            await runCommand(`taskkill /F /IM ${exePath}`); +            await runCommand(`taskkill /F /IM run.exe`);            } catch (e: any) {              console.log(                "Failed to kill old server second time on windows with taskkill:", @@ -126,14 +127,9 @@ async function checkOrKillRunningServer(serverUrl: string): Promise<boolean> {        fs.unlinkSync(serverVersionPath());      }      // Also delete the server binary -    const serverBinaryPath = path.join( -      getExtensionUri().fsPath, -      "server", -      "exe", -      `run${os.platform() === "win32" ? ".exe" : ""}` -    ); -    if (fs.existsSync(serverBinaryPath)) { -      fs.unlinkSync(serverBinaryPath); +    const serverBinary = serverBinaryPath(); +    if (fs.existsSync(serverBinary)) { +      fs.unlinkSync(serverBinary);      }    } @@ -213,12 +209,7 @@ export async function startContinuePythonServer(redownload: boolean = true) {          : "mac/run"        : "linux/run"; -  const destination = path.join( -    getExtensionUri().fsPath, -    "server", -    "exe", -    `run${os.platform() === "win32" ? ".exe" : ""}` -  ); +  const destination = serverBinaryPath();    // First, check if the server is already downloaded    let shouldDownload = true; diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 94997d76..353584e9 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -272,40 +272,10 @@ class IdeProtocolClient {          break;        case "listDirectoryContents":          messenger.send("listDirectoryContents", { -          contents: ( -            await vscode.workspace.fs.readDirectory( -              uriFromFilePath(data.directory) -            ) -          ) -            .map(([name, type]) => name) -            .filter((name) => { -              const DEFAULT_IGNORE_DIRS = [ -                ".git", -                ".vscode", -                ".idea", -                ".vs", -                ".venv", -                "env", -                ".env", -                "node_modules", -                "dist", -                "build", -                "target", -                "out", -                "bin", -                ".pytest_cache", -                ".vscode-test", -                ".continue", -                "__pycache__", -              ]; -              if ( -                !DEFAULT_IGNORE_DIRS.some((dir) => -                  name.split(path.sep).includes(dir) -                ) -              ) { -                return name; -              } -            }), +          contents: await this.getDirectoryContents( +            data.directory, +            data.recursive || false +          ),          });          break;        case "editFile": @@ -562,6 +532,57 @@ class IdeProtocolClient {        });    } +  async getDirectoryContents( +    directory: string, +    recursive: boolean +  ): Promise<string[]> { +    let nameAndType = ( +      await vscode.workspace.fs.readDirectory(uriFromFilePath(directory)) +    ).filter(([name, type]) => { +      const DEFAULT_IGNORE_DIRS = [ +        ".git", +        ".vscode", +        ".idea", +        ".vs", +        ".venv", +        "env", +        ".env", +        "node_modules", +        "dist", +        "build", +        "target", +        "out", +        "bin", +        ".pytest_cache", +        ".vscode-test", +        ".continue", +        "__pycache__", +      ]; +      if ( +        !DEFAULT_IGNORE_DIRS.some((dir) => name.split(path.sep).includes(dir)) +      ) { +        return name; +      } +    }); + +    let absolutePaths = nameAndType +      .filter(([name, type]) => type === vscode.FileType.File) +      .map(([name, type]) => path.join(directory, name)); +    if (recursive) { +      for (const [name, type] of nameAndType) { +        if (type === vscode.FileType.Directory) { +          const subdirectory = path.join(directory, name); +          const subdirectoryContents = await this.getDirectoryContents( +            subdirectory, +            recursive +          ); +          absolutePaths = absolutePaths.concat(subdirectoryContents); +        } +      } +    } +    return absolutePaths; +  } +    async readFile(filepath: string): Promise<string> {      let contents: string | undefined;      if (typeof contents === "undefined") { | 
