(pos: number, cell: CodeCellType)
| 328 | } |
| 329 | |
| 330 | async function onGetDefinitionContents(pos: number, cell: CodeCellType): Promise<string> { |
| 331 | return new Promise((resolve, reject) => { |
| 332 | if (!channel) { |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | async function gotoDefCallback({ response }: TsServerDefinitionLocationResponsePayloadType) { |
| 337 | if (!channel) { |
| 338 | return; |
| 339 | } |
| 340 | |
| 341 | channel.off('tsserver:cell:definition_location:response', gotoDefCallback); |
| 342 | if (response === null) { |
| 343 | reject(new Error(`Error fetching file content: no response!`)); |
| 344 | return; |
| 345 | } |
| 346 | const file_response = await getFileContent(response.file); |
| 347 | if (file_response.result.type === 'cell') { |
| 348 | document |
| 349 | .getElementById(file_response.result.filename) |
| 350 | ?.scrollIntoView({ behavior: 'smooth' }); |
| 351 | } else { |
| 352 | if (file_response.error) { |
| 353 | reject(new Error(`Error fetching file content: ${file_response.result}`)); |
| 354 | } else { |
| 355 | resolve(file_response.result.content); |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | channel.on('tsserver:cell:definition_location:response', gotoDefCallback); |
| 361 | channel.push('tsserver:cell:definition_location:request', { |
| 362 | cellId: cell.id, |
| 363 | request: { location: mapCMLocationToTsServer(cell.source, pos) }, |
| 364 | }); |
| 365 | }); |
| 366 | } |
| 367 | |
| 368 | // The order of these extensions is important. |
| 369 | // We want the errors to be first, so we call tsLinter before tsHover. |
no test coverage detected