summaryrefslogtreecommitdiff
path: root/extension/src/suggestions.ts
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-27 09:51:37 -0700
committerNate Sesti <sestinj@gmail.com>2023-06-27 09:51:37 -0700
commit4c832d0620ac4135b0a0bb94985ca92372dd5eb4 (patch)
tree53517bc9ddc521853f99e2a9ee3f6afc1c74e128 /extension/src/suggestions.ts
parent21110bb7277b09a40b367d336f9eb318a874426e (diff)
downloadsncontinue-4c832d0620ac4135b0a0bb94985ca92372dd5eb4.tar.gz
sncontinue-4c832d0620ac4135b0a0bb94985ca92372dd5eb4.tar.bz2
sncontinue-4c832d0620ac4135b0a0bb94985ca92372dd5eb4.zip
accept/reject all
Diffstat (limited to 'extension/src/suggestions.ts')
-rw-r--r--extension/src/suggestions.ts32
1 files changed, 29 insertions, 3 deletions
diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts
index 9b358899..4631c33e 100644
--- a/extension/src/suggestions.ts
+++ b/extension/src/suggestions.ts
@@ -238,6 +238,26 @@ export function acceptSuggestionCommand(key: SuggestionRanges | null = null) {
selectSuggestion("selected", key);
}
+function handleAllSuggestions(accept: boolean) {
+ const editor = vscode.window.activeTextEditor;
+ if (!editor) return;
+ const editorUri = editor.document.uri.toString();
+ const suggestions = editorToSuggestions.get(editorUri);
+ if (!suggestions) return;
+
+ while (suggestions.length > 0) {
+ selectSuggestion(accept ? "new" : "old");
+ }
+}
+
+export function acceptAllSuggestionsCommand() {
+ handleAllSuggestions(true);
+}
+
+export function rejectAllSuggestionsCommand() {
+ handleAllSuggestions(false);
+}
+
export async function rejectSuggestionCommand(
key: SuggestionRanges | null = null
) {
@@ -292,9 +312,15 @@ export async function showSuggestion(
return new Promise((resolve, reject) => {
editor!
- .edit((edit) => {
- edit.insert(new vscode.Position(range.end.line, 0), suggestion + "\n");
- })
+ .edit(
+ (edit) => {
+ edit.insert(
+ new vscode.Position(range.end.line, 0),
+ suggestion + "\n"
+ );
+ },
+ { undoStopBefore: false, undoStopAfter: false }
+ )
.then(
(success) => {
if (success) {