( range: vscode.Range, webviewProtocol: VsCodeWebviewProtocol, prompt?: string, )
| 153 | } |
| 154 | |
| 155 | export function addCodeToContextFromRange( |
| 156 | range: vscode.Range, |
| 157 | webviewProtocol: VsCodeWebviewProtocol, |
| 158 | prompt?: string, |
| 159 | ) { |
| 160 | const document = vscode.window.activeTextEditor?.document; |
| 161 | |
| 162 | if (!document) { |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | const rangeInFileWithContents = { |
| 167 | filepath: document.uri.toString(), |
| 168 | contents: document.getText(range), |
| 169 | range: { |
| 170 | start: { |
| 171 | line: range.start.line, |
| 172 | character: range.start.character, |
| 173 | }, |
| 174 | end: { |
| 175 | line: range.end.line, |
| 176 | character: range.end.character, |
| 177 | }, |
| 178 | }, |
| 179 | }; |
| 180 | |
| 181 | webviewProtocol?.request("highlightedCode", { |
| 182 | rangeInFileWithContents, |
| 183 | prompt, |
| 184 | // Assume `true` since range selection is currently only used for quick actions/fixes |
| 185 | shouldRun: true, |
| 186 | }); |
| 187 | } |
no test coverage detected