diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-06-27 09:51:37 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-06-27 09:51:37 -0700 | 
| commit | 5dfd7b8ee8d79c47bf39ea8a97872f1e2af23c35 (patch) | |
| tree | a57a7db561166481c08f935077aa9965589acada | |
| parent | 3ecd29eb6031be378d8c8f01a1e25259e04087e5 (diff) | |
| download | sncontinue-5dfd7b8ee8d79c47bf39ea8a97872f1e2af23c35.tar.gz sncontinue-5dfd7b8ee8d79c47bf39ea8a97872f1e2af23c35.tar.bz2 sncontinue-5dfd7b8ee8d79c47bf39ea8a97872f1e2af23c35.zip | |
accept/reject all
| -rw-r--r-- | extension/package.json | 20 | ||||
| -rw-r--r-- | extension/src/commands.ts | 4 | ||||
| -rw-r--r-- | extension/src/suggestions.ts | 32 | 
3 files changed, 53 insertions, 3 deletions
| diff --git a/extension/package.json b/extension/package.json index a9b8660b..63a49173 100644 --- a/extension/package.json +++ b/extension/package.json @@ -85,6 +85,16 @@          "command": "continue.rejectSuggestion",          "category": "Continue",          "title": "Reject Suggestion" +      }, +      { +        "command": "continue.acceptAllSuggestions", +        "category": "Continue", +        "title": "Accept All Suggestions" +      }, +      { +        "command": "continue.rejectAllSuggestions", +        "category": "Continue", +        "title": "Reject All Suggestions"        }      ],      "keybindings": [ @@ -107,6 +117,16 @@          "command": "continue.acceptSuggestion",          "mac": "shift+ctrl+enter",          "key": "shift+ctrl+enter" +      }, +      { +        "command": "continue.acceptAllSuggestions", +        "mac": "shift+cmd+enter", +        "key": "shift+ctrl+enter" +      }, +      { +        "command": "continue.rejectAllSuggestions", +        "mac": "shift+cmd+backspace", +        "key": "shift+ctrl+backspace"        }      ],      "menus": { diff --git a/extension/src/commands.ts b/extension/src/commands.ts index 22e15c43..424c238a 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -10,6 +10,8 @@ import {    rejectSuggestionCommand,    suggestionDownCommand,    suggestionUpCommand, +  acceptAllSuggestionsCommand, +  rejectAllSuggestionsCommand,  } from "./suggestions";  import * as bridge from "./bridge";  import { debugPanelWebview, setupDebugPanel } from "./debugPanel"; @@ -61,6 +63,8 @@ const commandsMap: { [command: string]: (...args: any) => any } = {    "continue.suggestionUp": suggestionUpCommand,    "continue.acceptSuggestion": acceptSuggestionCommand,    "continue.rejectSuggestion": rejectSuggestionCommand, +  "continue.acceptAllSuggestions": acceptAllSuggestionsCommand, +  "continue.rejectAllSuggestions": rejectAllSuggestionsCommand,    "continue.focusContinueInput": async () => {      vscode.commands.executeCommand("continue.continueGUIView.focus");      debugPanelWebview?.postMessage({ 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) { | 
