(message)
| 206 | } |
| 207 | |
| 208 | async function openSourceLocation(message) { |
| 209 | const file = typeof message.file === "string" ? message.file : ""; |
| 210 | if (!file || !path.isAbsolute(file)) { |
| 211 | throw new Error("source location did not include an absolute file path"); |
| 212 | } |
| 213 | |
| 214 | const line = positiveInteger(message.line); |
| 215 | const column = positiveInteger(message.column); |
| 216 | const document = await vscode.workspace.openTextDocument( |
| 217 | vscode.Uri.file(file), |
| 218 | ); |
| 219 | const position = new vscode.Position( |
| 220 | Math.max(0, (line ?? 1) - 1), |
| 221 | Math.max(0, (column ?? 1) - 1), |
| 222 | ); |
| 223 | |
| 224 | await vscode.window.showTextDocument(document, { |
| 225 | preview: true, |
| 226 | selection: new vscode.Range(position, position), |
| 227 | viewColumn: vscode.ViewColumn.Active, |
| 228 | }); |
| 229 | } |
| 230 | |
| 231 | function positiveInteger(value) { |
| 232 | return Number.isInteger(value) && value > 0 ? value : null; |
no test coverage detected