diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-18 19:05:35 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-18 19:05:35 -0700 |
commit | 90c76f81b4465d389ecef81aafa4d566b914669f (patch) | |
tree | 1831820f35acc4cbe1f13f6552f3e8ed212e1c35 /extension/src/diffs.ts | |
parent | 627f260cee108476e5335584e81f5e36f3e248cb (diff) | |
download | sncontinue-90c76f81b4465d389ecef81aafa4d566b914669f.tar.gz sncontinue-90c76f81b4465d389ecef81aafa4d566b914669f.tar.bz2 sncontinue-90c76f81b4465d389ecef81aafa4d566b914669f.zip |
fix "can't edit twice" bug
Diffstat (limited to 'extension/src/diffs.ts')
-rw-r--r-- | extension/src/diffs.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 1e63c5f6..1130a06a 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -38,6 +38,15 @@ class DiffManager { constructor() { this.setupDirectory(); + + // Listen for file closes, and if it's a diff file, clean up + vscode.workspace.onDidCloseTextDocument((document) => { + const newFilepath = document.uri.fsPath; + const diffInfo = this.diffs.get(newFilepath); + if (diffInfo) { + this.cleanUpDiff(diffInfo, false); + } + }); } private escapeFilepath(filepath: string): string { @@ -160,9 +169,9 @@ class DiffManager { return newFilepath; } - cleanUpDiff(diffInfo: DiffInfo) { + cleanUpDiff(diffInfo: DiffInfo, hideEditor: boolean = true) { // Close the editor, remove the record, delete the file - if (diffInfo.editor) { + if (hideEditor && diffInfo.editor) { vscode.window.showTextDocument(diffInfo.editor.document); vscode.commands.executeCommand("workbench.action.closeActiveEditor"); } |