diff options
| author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-07-02 20:15:49 -0700 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-02 20:15:49 -0700 | 
| commit | cf3d08ceaabecd80b20aaac24c5c166cd8e6472f (patch) | |
| tree | 7559fe0d9500d5156fa99ee5614ac0fe6d4e88f3 /extension/src | |
| parent | 0ffd2648d679916872c681036a68741a83d80c0e (diff) | |
| parent | 0a812994703791023125177fe4820202374e45b0 (diff) | |
| download | sncontinue-cf3d08ceaabecd80b20aaac24c5c166cd8e6472f.tar.gz sncontinue-cf3d08ceaabecd80b20aaac24c5c166cd8e6472f.tar.bz2 sncontinue-cf3d08ceaabecd80b20aaac24c5c166cd8e6472f.zip | |
Merge pull request #170 from continuedev/explicit-context
Explicit context
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 });    } | 
