(coord: any)
| 365 | |
| 366 | //utils |
| 367 | function toVSCCoord(coord: any) { |
| 368 | // this is necessary because RStudio will accept negative or infinite values, |
| 369 | // replacing them with the min or max or the document. |
| 370 | // These must be clamped non-negative integers accepted by VSCode. |
| 371 | // For Inf, we set the value to a very large integer, relying on the |
| 372 | // parsing functions to revise this down using the validatePosition/Range functions. |
| 373 | let coord_value: number; |
| 374 | if (coord === 'Inf') { |
| 375 | coord_value = 10000000; |
| 376 | } else if (coord === '-Inf') { |
| 377 | coord_value = 0; |
| 378 | } else if (coord <= 0) { |
| 379 | coord_value = 0; |
| 380 | } |
| 381 | else { // coord > 0 |
| 382 | coord_value = coord - 1; // positions in the rstudioapi are 1 indexed. |
| 383 | } |
| 384 | |
| 385 | return coord_value; |
| 386 | |
| 387 | } |
| 388 | |
| 389 | function parsePosition(rs_position: any[], targetDocument: TextDocument) { |
| 390 | if (rs_position.length !== 2) { |
no outgoing calls
no test coverage detected