diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-06 09:26:54 -0400 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-06 09:26:54 -0400 |
commit | 5cb69176f731d6e93802e29eb37c5c5d83003be2 (patch) | |
tree | 5cdd3b786e0391648a265be117c53f9162f64f18 /extension/src | |
parent | 9f33cac01eef7cbe15dafb4bd51666195f120d69 (diff) | |
parent | 60eaf08df63b77ce31ce8afaa77fdd6b357c8a8a (diff) | |
download | sncontinue-5cb69176f731d6e93802e29eb37c5c5d83003be2.tar.gz sncontinue-5cb69176f731d6e93802e29eb37c5c5d83003be2.tar.bz2 sncontinue-5cb69176f731d6e93802e29eb37c5c5d83003be2.zip |
Merge branch 'design'
Diffstat (limited to 'extension/src')
-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... } } |