diff options
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/activation/activate.ts | 2 | ||||
| -rw-r--r-- | extension/src/commands.ts | 37 | ||||
| -rw-r--r-- | extension/src/continueIdeClient.ts | 78 | ||||
| -rw-r--r-- | extension/src/diffs.ts | 21 | ||||
| -rw-r--r-- | extension/src/util/util.ts | 2 | 
5 files changed, 93 insertions, 47 deletions
diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index 7481c211..0dce250c 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -93,4 +93,6 @@ export async function activateExtension(context: vscode.ExtensionContext) {        }      )    ); + +  vscode.commands.executeCommand("continue.focusContinueInput");  } diff --git a/extension/src/commands.ts b/extension/src/commands.ts index 479e8db0..4e2f4571 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -9,6 +9,36 @@ import { ideProtocolClient } from "./activation/activate";  let focusedOnContinueInput = false; +function addHighlightedCodeToContext(edit: boolean) { +  focusedOnContinueInput = !focusedOnContinueInput; +  const editor = vscode.window.activeTextEditor; +  if (editor) { +    const selection = editor.selection; +    if (selection.isEmpty) return; +    const range = new vscode.Range(selection.start, selection.end); +    const contents = editor.document.getText(range); +    ideProtocolClient?.sendHighlightedCode( +      [ +        { +          filepath: editor.document.uri.fsPath, +          contents, +          range: { +            start: { +              line: selection.start.line, +              character: selection.start.character, +            }, +            end: { +              line: selection.end.line, +              character: selection.end.character, +            }, +          }, +        }, +      ], +      edit +    ); +  } +} +  export const setFocusedOnContinueInput = (value: boolean) => {    focusedOnContinueInput = value;  }; @@ -32,11 +62,11 @@ const commandsMap: { [command: string]: (...args: any) => any } = {      debugPanelWebview?.postMessage({        type: "focusContinueInput",      }); - -    focusedOnContinueInput = !focusedOnContinueInput; +    addHighlightedCodeToContext(false);    },    "continue.focusContinueInputWithEdit": async () => {      vscode.commands.executeCommand("continue.continueGUIView.focus"); +    addHighlightedCodeToContext(true);      debugPanelWebview?.postMessage({        type: "focusContinueInputWithEdit",      }); @@ -47,8 +77,7 @@ const commandsMap: { [command: string]: (...args: any) => any } = {    },    "continue.quickTextEntry": async () => {      const text = await vscode.window.showInputBox({ -      placeHolder: -        "Ask a question or enter a slash command", +      placeHolder: "Ask a question or enter a slash command",        title: "Continue Quick Input",      });      if (text) { diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 5c04e351..e2c86bdf 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -176,37 +176,37 @@ class IdeProtocolClient {      });      // Setup listeners for any selection changes in open editors -    vscode.window.onDidChangeTextEditorSelection((event) => { -      if (!this.editorIsCode(event.textEditor)) { -        return; -      } -      if (this._highlightDebounce) { -        clearTimeout(this._highlightDebounce); -      } -      this._highlightDebounce = setTimeout(() => { -        const highlightedCode = event.textEditor.selections -          .filter((s) => !s.isEmpty) -          .map((selection) => { -            const range = new vscode.Range(selection.start, selection.end); -            const contents = event.textEditor.document.getText(range); -            return { -              filepath: event.textEditor.document.uri.fsPath, -              contents, -              range: { -                start: { -                  line: selection.start.line, -                  character: selection.start.character, -                }, -                end: { -                  line: selection.end.line, -                  character: selection.end.character, -                }, -              }, -            }; -          }); -        this.sendHighlightedCode(highlightedCode); -      }, 100); -    }); +    // vscode.window.onDidChangeTextEditorSelection((event) => { +    //   if (!this.editorIsCode(event.textEditor)) { +    //     return; +    //   } +    //   if (this._highlightDebounce) { +    //     clearTimeout(this._highlightDebounce); +    //   } +    //   this._highlightDebounce = setTimeout(() => { +    //     const highlightedCode = event.textEditor.selections +    //       .filter((s) => !s.isEmpty) +    //       .map((selection) => { +    //         const range = new vscode.Range(selection.start, selection.end); +    //         const contents = event.textEditor.document.getText(range); +    //         return { +    //           filepath: event.textEditor.document.uri.fsPath, +    //           contents, +    //           range: { +    //             start: { +    //               line: selection.start.line, +    //               character: selection.start.character, +    //             }, +    //             end: { +    //               line: selection.end.line, +    //               character: selection.end.character, +    //             }, +    //           }, +    //         }; +    //       }); +    //     this.sendHighlightedCode(highlightedCode); +    //   }, 100); +    // });      // Register a content provider for the readonly virtual documents      const documentContentProvider = new (class @@ -659,6 +659,11 @@ class IdeProtocolClient {      );      const terminalContents = await vscode.env.clipboard.readText();      await vscode.env.clipboard.writeText(tempCopyBuffer); + +    if (tempCopyBuffer === terminalContents) { +      // This means there is no terminal open to select text from +      return ""; +    }      return terminalContents;    } @@ -729,16 +734,19 @@ class IdeProtocolClient {      this.messenger?.send("commandOutput", { output });    } -  sendHighlightedCode(highlightedCode: (RangeInFile & { contents: string })[]) { -    this.messenger?.send("highlightedCodePush", { highlightedCode }); +  sendHighlightedCode( +    highlightedCode: (RangeInFile & { contents: string })[], +    edit?: boolean +  ) { +    this.messenger?.send("highlightedCodePush", { highlightedCode, edit });    }    sendAcceptRejectSuggestion(accepted: boolean) {      this.messenger?.send("acceptRejectSuggestion", { accepted });    } -  sendAcceptRejectDiff(accepted: boolean) { -    this.messenger?.send("acceptRejectDiff", { accepted }); +  sendAcceptRejectDiff(accepted: boolean, stepIndex: number) { +    this.messenger?.send("acceptRejectDiff", { accepted, stepIndex });    }    sendMainUserInput(input: string) { diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 4c077a25..426415fc 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -3,7 +3,7 @@ import * as path from "path";  import * as fs from "fs";  import * as vscode from "vscode";  import { extensionContext, ideProtocolClient } from "./activation/activate"; -import { getMetaKeyLabel } from "./util/util"; +import { getMetaKeyLabel, getPlatform } from "./util/util";  import { devDataPath } from "./activation/environmentSetup";  import { uriFromFilePath } from "./util/vscode"; @@ -194,10 +194,15 @@ class DiffManager {        this.diffs.set(newFilepath, diffInfo);      } -    vscode.commands.executeCommand( -      "workbench.action.files.revert", -      uriFromFilePath(newFilepath) -    ); +    if (getPlatform() === "windows") { +      // Just a matter of how it renders +      // Lags on windows without this +      // Flashes too much on mac with it +      vscode.commands.executeCommand( +        "workbench.action.files.revert", +        uriFromFilePath(newFilepath) +      ); +    }      return newFilepath;    } @@ -271,6 +276,8 @@ class DiffManager {        });      await recordAcceptReject(true, diffInfo); + +    ideProtocolClient.sendAcceptRejectDiff(true, diffInfo.step_index);    }    async rejectDiff(newFilepath?: string) { @@ -302,6 +309,8 @@ class DiffManager {        });      await recordAcceptReject(false, diffInfo); + +    ideProtocolClient.sendAcceptRejectDiff(false, diffInfo.step_index);    }  } @@ -339,10 +348,8 @@ async function recordAcceptReject(accepted: boolean, diffInfo: DiffInfo) {  export async function acceptDiffCommand(newFilepath?: string) {    await diffManager.acceptDiff(newFilepath); -  ideProtocolClient.sendAcceptRejectDiff(true);  }  export async function rejectDiffCommand(newFilepath?: string) {    await diffManager.rejectDiff(newFilepath); -  ideProtocolClient.sendAcceptRejectDiff(false);  } diff --git a/extension/src/util/util.ts b/extension/src/util/util.ts index 38c955e7..1ce4a8aa 100644 --- a/extension/src/util/util.ts +++ b/extension/src/util/util.ts @@ -65,7 +65,7 @@ export function debounced(delay: number, fn: Function) {  type Platform = "mac" | "linux" | "windows" | "unknown"; -function getPlatform(): Platform { +export function getPlatform(): Platform {    const platform = os.platform();    if (platform === "darwin") {      return "mac";  | 
