MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / toVSCCoord

Function toVSCCoord

src/rstudioapi.ts:367–387  ·  view source on GitHub ↗
(coord: any)

Source from the content-addressed store, hash-verified

365
366//utils
367function 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
389function parsePosition(rs_position: any[], targetDocument: TextDocument) {
390 if (rs_position.length !== 2) {

Callers 2

parsePositionFunction · 0.85
parseRangeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected