From 4428acdd6f372c3724a908fafb1c793e0eae4096 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 27 Aug 2023 01:43:54 -0700 Subject: fix: :bug: additional fixes to ssh /edit --- extension/src/diffs.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index f28203e6..f8b311f7 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -28,6 +28,7 @@ async function writeFile(path: string, contents: string) { ); } +// THIS IS LOCAL export const DIFF_DIRECTORY = path .join(os.homedir(), ".continue", "diffs") .replace(/^C:/, "c:"); @@ -43,7 +44,11 @@ class DiffManager { private async setupDirectory() { // Make sure the diff directory exists - await vscode.workspace.fs.createDirectory(uriFromFilePath(DIFF_DIRECTORY)); + if (!fs.existsSync(DIFF_DIRECTORY)) { + fs.mkdirSync(DIFF_DIRECTORY, { + recursive: true, + }); + } } constructor() { @@ -96,7 +101,7 @@ class DiffManager { const editor = vscode.window.activeTextEditor; if (!editor) { - throw new Error("No active text editor found for Continue Diff"); + return; } // Change the vscode setting to allow codeLens in diff editor @@ -187,8 +192,13 @@ class DiffManager { cleanUpDiff(diffInfo: DiffInfo, hideEditor: boolean = true) { // Close the editor, remove the record, delete the file if (hideEditor && diffInfo.editor) { - vscode.window.showTextDocument(diffInfo.editor.document); - vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + try { + vscode.window.showTextDocument(diffInfo.editor.document); + vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + } catch { + } finally { + vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + } } this.diffs.delete(diffInfo.newFilepath); fs.unlinkSync(diffInfo.newFilepath); -- cgit v1.2.3-70-g09d2