diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-07-02 21:59:11 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-07-02 21:59:11 -0700 | 
| commit | 527c5c7ce2a1605935814e83e851d7539d12e6d0 (patch) | |
| tree | 619878c7279c376b4ff9c949c898938c822dce6e /extension/src | |
| parent | f9ea4f84da154d0c3391d572ce958bc6bb4a96cd (diff) | |
| parent | cf3d08ceaabecd80b20aaac24c5c166cd8e6472f (diff) | |
| download | sncontinue-527c5c7ce2a1605935814e83e851d7539d12e6d0.tar.gz sncontinue-527c5c7ce2a1605935814e83e851d7539d12e6d0.tar.bz2 sncontinue-527c5c7ce2a1605935814e83e851d7539d12e6d0.zip | |
Merge branch 'main' of https://github.com/continuedev/continue
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/continueIdeClient.ts | 39 | 
1 files changed, 36 insertions, 3 deletions
| diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index b39e6565..999bca88 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -12,18 +12,17 @@ import {    acceptSuggestionCommand,    rejectSuggestionCommand,  } from "./suggestions"; -import { debugPanelWebview, setupDebugPanel } from "./debugPanel";  import { FileEditWithFullContents } from "../schema/FileEditWithFullContents";  import fs = require("fs");  import { WebsocketMessenger } from "./util/messenger"; -import { decorationManager } from "./decorations"; -  class IdeProtocolClient {    private messenger: WebsocketMessenger | null = null;    private readonly context: vscode.ExtensionContext;    private _makingEdit = 0; +  private _highlightDebounce: NodeJS.Timeout | null = null; +    constructor(serverUrl: string, context: vscode.ExtensionContext) {      this.context = context; @@ -65,6 +64,36 @@ class IdeProtocolClient {      //     this._makingEdit--;      //   }      // }); + +    // Setup listeners for any file changes in open editors +    vscode.window.onDidChangeTextEditorSelection((event) => { +      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); +    });    }    async handleMessage( @@ -376,6 +405,10 @@ class IdeProtocolClient {      this.messenger?.send("commandOutput", { output });    } +  sendHighlightedCode(highlightedCode: (RangeInFile & { contents: string })[]) { +    this.messenger?.send("highlightedCodePush", { highlightedCode }); +  } +    sendAcceptRejectSuggestion(accepted: boolean) {      this.messenger?.send("acceptRejectSuggestion", { accepted });    } | 
