| 25 | } |
| 26 | |
| 27 | LineCol LineIndex::GetLineCol(std::size_t offset) { |
| 28 | auto lineIt = std::partition_point( |
| 29 | _newLines.begin(), _newLines.end(), |
| 30 | [offset](LineOffset &lo) { |
| 31 | return lo.Start <= offset; |
| 32 | }); |
| 33 | std::size_t line = 0; |
| 34 | if (lineIt > _newLines.begin()) { |
| 35 | line = static_cast<std::size_t>(lineIt - _newLines.begin() - 1); |
| 36 | } |
| 37 | auto lineStartOffset = _newLines.at(line).Start; |
| 38 | auto colOffset = offset - lineStartOffset; |
| 39 | auto col = _newLines.at(line).GetCol(colOffset); |
| 40 | return {line, col}; |
| 41 | } |
| 42 | |
| 43 | std::size_t LineIndex::GetOffset(const LineCol &lineCol) { |
| 44 | if (lineCol.Line < _newLines.size()) { |
no test coverage detected