summaryrefslogtreecommitdiff
path: root/extension/src/diffs.ts
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-05 20:35:59 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-05 20:35:59 -0700
commitd259979ef89f17957396fc7300e1ecf54214ae84 (patch)
treef953d25bae598ae079abe1bc0a6375198f3df5f0 /extension/src/diffs.ts
parentec408c7654cb74398a78a7348609635760926114 (diff)
downloadsncontinue-d259979ef89f17957396fc7300e1ecf54214ae84.tar.gz
sncontinue-d259979ef89f17957396fc7300e1ecf54214ae84.tar.bz2
sncontinue-d259979ef89f17957396fc7300e1ecf54214ae84.zip
stuff
Diffstat (limited to 'extension/src/diffs.ts')
-rw-r--r--extension/src/diffs.ts22
1 files changed, 18 insertions, 4 deletions
diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts
index 178b1a9d..1b8888e8 100644
--- a/extension/src/diffs.ts
+++ b/extension/src/diffs.ts
@@ -92,7 +92,14 @@ class DiffManager {
fs.unlinkSync(diffInfo.newFilepath);
}
- acceptDiff(newFilepath: string) {
+ acceptDiff(newFilepath?: string) {
+ // If no newFilepath is provided and there is only one in the dictionary, use that
+ if (!newFilepath && this.diffs.size === 1) {
+ newFilepath = Array.from(this.diffs.keys())[0];
+ }
+ if (!newFilepath) {
+ 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) {
@@ -105,7 +112,14 @@ class DiffManager {
this.cleanUpDiff(diffInfo);
}
- rejectDiff(newFilepath: string) {
+ rejectDiff(newFilepath?: string) {
+ // If no newFilepath is provided and there is only one in the dictionary, use that
+ if (!newFilepath && this.diffs.size === 1) {
+ newFilepath = Array.from(this.diffs.keys())[0];
+ }
+ if (!newFilepath) {
+ return;
+ }
const diffInfo = this.diffs.get(newFilepath);
if (!diffInfo) {
return;
@@ -117,10 +131,10 @@ class DiffManager {
export const diffManager = new DiffManager();
-export async function acceptDiffCommand(newFilepath: string) {
+export async function acceptDiffCommand(newFilepath?: string) {
diffManager.acceptDiff(newFilepath);
}
-export async function rejectDiffCommand(newFilepath: string) {
+export async function rejectDiffCommand(newFilepath?: string) {
diffManager.rejectDiff(newFilepath);
}