diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-06 00:21:15 -0400 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-06 00:21:15 -0400 |
commit | 04aa13340b7a621a9ff678a3c0cfc1d9aa9fb646 (patch) | |
tree | ad6acb284566c9ad4bda6eaf78ad5283368e86f4 /extension/src/continueIdeClient.ts | |
parent | 9cda43f842b2489ce3119f43596a1a8a997adeb2 (diff) | |
download | sncontinue-04aa13340b7a621a9ff678a3c0cfc1d9aa9fb646.tar.gz sncontinue-04aa13340b7a621a9ff678a3c0cfc1d9aa9fb646.tar.bz2 sncontinue-04aa13340b7a621a9ff678a3c0cfc1d9aa9fb646.zip |
many design improvements
Diffstat (limited to 'extension/src/continueIdeClient.ts')
-rw-r--r-- | extension/src/continueIdeClient.ts | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index a5a1c5dc..25287d32 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -96,6 +96,12 @@ class IdeProtocolClient { fileEdit, }); break; + case "highlightCode": + this.highlightCode(data.rangeInFile, data.color); + break; + case "runCommand": + this.runCommand(data.command); + break; case "saveFile": this.saveFile(data.filepath); break; @@ -117,6 +123,28 @@ class IdeProtocolClient { // ------------------------------------ // // On message handlers + async highlightCode(rangeInFile: RangeInFile, color: string) { + const range = new vscode.Range( + rangeInFile.range.start.line, + rangeInFile.range.start.character, + rangeInFile.range.end.line, + rangeInFile.range.end.character + ); + const editor = await openEditorAndRevealRange( + rangeInFile.filepath, + range, + vscode.ViewColumn.One + ); + if (editor) { + editor.setDecorations( + vscode.window.createTextEditorDecorationType({ + backgroundColor: color, + }), + [range] + ); + } + } + showSuggestion(edit: FileEdit) { // showSuggestion already exists showSuggestion( @@ -289,7 +317,16 @@ class IdeProtocolClient { } runCommand(command: string) { - vscode.window.terminals[0].sendText(command, true); + if (vscode.window.terminals.length === 0) { + const terminal = vscode.window.createTerminal(); + terminal.show(); + terminal.sendText("bash", true); + terminal.sendText(command, true); + return; + } + const terminal = vscode.window.terminals[0]; + terminal.show(); + terminal.sendText(command, true); // But need to know when it's done executing... } } |