| 116 | } |
| 117 | |
| 118 | function positionLength(input: string, start = 0, end = input.length): Position { |
| 119 | let match: RegExpExecArray; |
| 120 | let line = 0; |
| 121 | lineBreakG.lastIndex = start; |
| 122 | while ((match = lineBreakG.exec(input)) && match.index < end) { |
| 123 | ++line; |
| 124 | start = match.index + match[0].length; |
| 125 | } |
| 126 | return {line, column: end - start}; |
| 127 | } |
| 128 | |
| 129 | function positionSubtract(b: Position, a: Position): Position { |
| 130 | return b.line === a.line ? {line: 0, column: b.column - a.column} : {line: b.line - a.line, column: b.column}; |