MCPcopy
hub / github.com/microsoft/pyright / convertPositionToOffset

Function convertPositionToOffset

server/src/common/positionUtils.ts:51–58  ·  view source on GitHub ↗
(position: DiagnosticTextPosition,
        lines: TextRangeCollection<TextRange>)

Source from the content-addressed store, hash-verified

49
50// Translates a position (line and col) into a file offset.
51export function convertPositionToOffset(position: DiagnosticTextPosition,
52 lines: TextRangeCollection<TextRange>): number | undefined {
53 if (position.line >= lines.count) {
54 return undefined;
55 }
56
57 return lines.getItemAt(position.line).start + position.column;
58}

Callers 3

getHoverForPositionMethod · 0.90
findNodeByPositionMethod · 0.90

Calls 1

getItemAtMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…