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 | 60eaf08df63b77ce31ce8afaa77fdd6b357c8a8a (patch) | |
tree | 3829dddf518ada1dcdbdda12716ce4ee39a5a500 /extension/src | |
parent | 8e5f5fc5c92ebc77578ffda5ce1fbc35bea60016 (diff) | |
download | sncontinue-60eaf08df63b77ce31ce8afaa77fdd6b357c8a8a.tar.gz sncontinue-60eaf08df63b77ce31ce8afaa77fdd6b357c8a8a.tar.bz2 sncontinue-60eaf08df63b77ce31ce8afaa77fdd6b357c8a8a.zip |
many design improvements
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... } } |