summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-11 00:51:42 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-11 00:51:42 -0700
commit50adabaef68917a65b123dbf6026c410b8c5a006 (patch)
tree02ef6127fbdbd03bdbdad842bd08ae3e47c2e10d
parentcec0a7df727255b61d5edb4208d286dc17e81096 (diff)
downloadsncontinue-50adabaef68917a65b123dbf6026c410b8c5a006.tar.gz
sncontinue-50adabaef68917a65b123dbf6026c410b8c5a006.tar.bz2
sncontinue-50adabaef68917a65b123dbf6026c410b8c5a006.zip
don't allow /edit in diff editor, save diff editor
-rw-r--r--continuedev/src/continuedev/steps/main.py10
-rw-r--r--extension/src/diffs.ts17
2 files changed, 21 insertions, 6 deletions
diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py
index 4f543022..2a8cd250 100644
--- a/continuedev/src/continuedev/steps/main.py
+++ b/continuedev/src/continuedev/steps/main.py
@@ -10,7 +10,7 @@ from ..models.filesystem import RangeInFile, RangeInFileWithContents
from ..core.observation import Observation, TextObservation, TracebackObservation
from ..libs.llm.prompt_utils import MarkdownStyleEncoderDecoder
from textwrap import dedent
-from ..core.main import Step
+from ..core.main import ContinueCustomException, Step
from ..core.sdk import ContinueSDK, Models
from ..core.observation import Observation
import subprocess
@@ -251,6 +251,9 @@ class EditHighlightedCodeStep(Step):
highlighted_code = await sdk.ide.getHighlightedCode()
if highlighted_code is not None:
for rif in highlighted_code:
+ if os.path.dirname(rif.filepath) == os.path.expanduser(os.path.join("~", ".continue", "diffs")):
+ raise ContinueCustomException(
+ message="Please accept or reject the change before making another edit in this file.", title="Accept/Reject First")
if rif.range.start == rif.range.end:
range_in_files.append(
RangeInFileWithContents.from_range_in_file(rif, ""))
@@ -278,6 +281,11 @@ class EditHighlightedCodeStep(Step):
filepath=x.filepath, range=x.range
), range_in_files))
+ for range_in_file in range_in_files:
+ if os.path.dirname(range_in_file.filepath) == os.path.expanduser(os.path.join("~", ".continue", "diffs")):
+ self.description = "Please accept or reject the change before making another edit in this file."
+ return
+
await sdk.run_step(DefaultModelEditCodeStep(user_input=self.user_input, range_in_files=range_in_files))
diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts
index b9ef8384..1dc292e1 100644
--- a/extension/src/diffs.ts
+++ b/extension/src/diffs.ts
@@ -132,11 +132,18 @@ class DiffManager {
console.log("No corresponding diffInfo found for newFilepath");
return;
}
- fs.writeFileSync(
- diffInfo.originalFilepath,
- fs.readFileSync(diffInfo.newFilepath)
- );
- this.cleanUpDiff(diffInfo);
+
+ // Save the right-side file, then copy over to original
+ vscode.workspace.textDocuments
+ .find((doc) => doc.uri.fsPath === newFilepath)
+ ?.save()
+ .then(() => {
+ fs.writeFileSync(
+ diffInfo.originalFilepath,
+ fs.readFileSync(diffInfo.newFilepath)
+ );
+ this.cleanUpDiff(diffInfo);
+ });
}
rejectDiff(newFilepath?: string) {