diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-08-27 16:52:04 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-08-27 16:52:04 -0700 | 
| commit | cda1be46625abd8f44962cceeded04c8c47d9f65 (patch) | |
| tree | 7d885deb957ae66775e8fd7011df1701bfd5239b /extension/src | |
| parent | 1d83a859645e14c534bbcef1e65e24772200e041 (diff) | |
| download | sncontinue-cda1be46625abd8f44962cceeded04c8c47d9f65.tar.gz sncontinue-cda1be46625abd8f44962cceeded04c8c47d9f65.tar.bz2 sncontinue-cda1be46625abd8f44962cceeded04c8c47d9f65.zip | |
fix: :bug: fix /edit in ssh, pinyin input in combobox
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/diffs.ts | 27 | 
1 files changed, 19 insertions, 8 deletions
| diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index e56878c8..98b8753a 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -65,7 +65,20 @@ class DiffManager {      return filepath.replace(/\\/g, "_").replace(/\//g, "_");    } +  private remoteTmpDir: string = "/tmp/continue";    private getNewFilepath(originalFilepath: string): string { +    if (vscode.env.remoteName) { +      // If we're in a remote, use the remote's temp directory +      // Doing this because there's no easy way to find the home directory, +      // and there aren't write permissions to the root directory +      // and writing these to local causes separate issues +      // because the vscode.diff command will always try to read from remote +      vscode.workspace.fs.createDirectory(uriFromFilePath(this.remoteTmpDir)); +      return path.join( +        this.remoteTmpDir, +        this.escapeFilepath(originalFilepath) +      ); +    }      return path.join(DIFF_DIRECTORY, this.escapeFilepath(originalFilepath));    } @@ -76,7 +89,8 @@ class DiffManager {      // If the file doesn't yet exist or the basename is a single digit number (vscode terminal), don't open the diff editor      try {        await vscode.workspace.fs.stat(uriFromFilePath(newFilepath)); -    } catch { +    } catch (e) { +      console.log("File doesn't exist, not opening diff editor", e);        return undefined;      }      if (path.basename(originalFilepath).match(/^\d$/)) { @@ -151,12 +165,12 @@ class DiffManager {      // Create or update existing diff      const newFilepath = this.getNewFilepath(originalFilepath); -    await writeFile(vscode.Uri.file(newFilepath), newContent); +    await writeFile(uriFromFilePath(newFilepath), newContent);      // Open the diff editor if this is a new diff      if (!this.diffs.has(newFilepath)) {        // Figure out the first line that is different -      const oldContent = await ideProtocolClient.readFile(originalFilepath); +      const oldContent = await readFile(originalFilepath);        const line = this._findFirstDifferentLine(oldContent, newContent);        const diffInfo: DiffInfo = { @@ -192,13 +206,10 @@ class DiffManager {        try {          vscode.window.showTextDocument(diffInfo.editor.document);          vscode.commands.executeCommand("workbench.action.closeActiveEditor"); -      } catch { -      } finally { -        vscode.commands.executeCommand("workbench.action.closeActiveEditor"); -      } +      } catch {}      }      this.diffs.delete(diffInfo.newFilepath); -    fs.unlinkSync(diffInfo.newFilepath); +    vscode.workspace.fs.delete(uriFromFilePath(diffInfo.newFilepath));    }    private inferNewFilepath() { | 
