summaryrefslogtreecommitdiff
path: root/extension/src/diffs.ts
diff options
context:
space:
mode:
authorTy Dunn <ty@tydunn.com>2023-07-10 15:25:34 -0700
committerTy Dunn <ty@tydunn.com>2023-07-10 15:25:34 -0700
commit9946701af5b551bc0e9caae57cb8119edad7a44e (patch)
tree38b9846a9eb78beb755ecc5408262cfe982f3f7a /extension/src/diffs.ts
parentb9525d5f0851d13b3d4936868f064810f3376dbd (diff)
parent20f4d07eb1d584569752e67c754951b7892e3e6b (diff)
downloadsncontinue-9946701af5b551bc0e9caae57cb8119edad7a44e.tar.gz
sncontinue-9946701af5b551bc0e9caae57cb8119edad7a44e.tar.bz2
sncontinue-9946701af5b551bc0e9caae57cb8119edad7a44e.zip
Merge branch 'main' of github.com:continuedev/continue
Diffstat (limited to 'extension/src/diffs.ts')
-rw-r--r--extension/src/diffs.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts
index dbfd8f59..b9ef8384 100644
--- a/extension/src/diffs.ts
+++ b/extension/src/diffs.ts
@@ -39,14 +39,25 @@ class DiffManager {
originalFilepath: string,
newFilepath: string
): vscode.TextEditor | undefined {
- // If the file doesn't yet exist, don't open the diff editor
- if (!fs.existsSync(newFilepath)) {
+ // If the file doesn't yet exist or the basename is a single digit number (git hash object or something), don't open the diff editor
+ if (
+ !fs.existsSync(newFilepath) ||
+ path.basename(originalFilepath).match(/^\d$/)
+ ) {
return undefined;
}
const rightUri = vscode.Uri.parse(newFilepath);
const leftUri = vscode.Uri.file(originalFilepath);
const title = "Continue Diff";
+ console.log(
+ "Opening diff window with ",
+ leftUri,
+ rightUri,
+ title,
+ newFilepath,
+ originalFilepath
+ );
vscode.commands.executeCommand("vscode.diff", leftUri, rightUri, title);
const editor = vscode.window.activeTextEditor;
@@ -112,11 +123,13 @@ class DiffManager {
newFilepath = Array.from(this.diffs.keys())[0];
}
if (!newFilepath) {
+ console.log("No newFilepath provided to accept the diff");
return;
}
// Get the diff info, copy new file to original, then delete from record and close the corresponding editor
const diffInfo = this.diffs.get(newFilepath);
if (!diffInfo) {
+ console.log("No corresponding diffInfo found for newFilepath");
return;
}
fs.writeFileSync(
@@ -132,10 +145,12 @@ class DiffManager {
newFilepath = Array.from(this.diffs.keys())[0];
}
if (!newFilepath) {
+ console.log("No newFilepath provided to reject the diff");
return;
}
const diffInfo = this.diffs.get(newFilepath);
if (!diffInfo) {
+ console.log("No corresponding diffInfo found for newFilepath");
return;
}