From 9fc831e7587cce99c8a6f2e56905c25068c8cab6 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 6 Jul 2023 21:44:01 -0700 Subject: fix: :bug: stop streaming on rejection --- extension/src/diffs.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'extension/src') diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 4fce744c..52a54046 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -38,7 +38,12 @@ class DiffManager { originalFilepath: string, newFilepath: string, newContent: string - ): vscode.TextEditor { + ): vscode.TextEditor | undefined { + // If the file doesn't yet exist, don't open the diff editor + if (!fs.existsSync(newFilepath)) { + return undefined; + } + const rightUri = vscode.Uri.parse(newFilepath); const leftUri = vscode.Uri.file(originalFilepath); const title = "Continue Diff"; @@ -73,6 +78,12 @@ class DiffManager { originalFilepath, newFilepath, }; + this.diffs.set(newFilepath, diffInfo); + } + + // Open the editor if it hasn't been opened yet + const diffInfo = this.diffs.get(newFilepath); + if (diffInfo && !diffInfo?.editor) { diffInfo.editor = this.openDiffEditor( originalFilepath, newFilepath, @@ -80,6 +91,7 @@ class DiffManager { ); this.diffs.set(newFilepath, diffInfo); } + return newFilepath; } @@ -89,7 +101,7 @@ class DiffManager { vscode.window.showTextDocument(diffInfo.editor.document); vscode.commands.executeCommand("workbench.action.closeActiveEditor"); } - this.diffs.delete(diffInfo.newFilepath); + // this.diffs.delete(diffInfo.newFilepath); fs.unlinkSync(diffInfo.newFilepath); } -- cgit v1.2.3-70-g09d2