368
369
export function parseLineAndColumnAware(rawPath: string): IPathWithLineAndColumn {
370
>
const segments = rawPath.split(':'); // C:\file.txt:<line>:<column>
extpath.ts
371
>
372
>
let path: string | undefined;
373
>
let line: number | undefined;
374
>
let column: number | undefined;
375
>
376
>
for (const segment of segments) {
377
>
const segmentAsNumber = Number(segment);
378
>
if (!isNumber(segmentAsNumber)) {
379
>
path = path ? [path, segment].join(':') : segment; // a colon can well be part of a path (e.g. C:\...)
380
>
} else if (line === undefined) {
381
>
line = segmentAsNumber;
382
>
} else if (column === undefined) {
383
>
column = segmentAsNumber;
384
>
}
385
>
}
386
>
387
>
if (!path) {
388
throw new Error('Format for `--goto` should be: `FILE:LINE(:COLUMN)`');
389
}
391
>
return {
392
>
path,
393
>
line: line !== undefined ? line : undefined,
394
>
column: column !== undefined ? column : line !== undefined ? 1 : undefined // if we have a line, make sure column is also set
395
>
};
396
>
}
397
398
const pathChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';