diff --git a/yaml/private/lex.nim b/yaml/private/lex.nim index 2361a73..3da66c5 100644 --- a/yaml/private/lex.nim +++ b/yaml/private/lex.nim @@ -218,31 +218,19 @@ proc lineWithMarker(lex: YamlLexer, pos: tuple[line, column: int], lineStartIndex = lex.sSource.pos lineEndIndex: int curLine = lex.sSource.line - let srcHigh = lex.sSource.src.high if pos.line == curLine: lineEndIndex = lex.sSource.pos - if lineEndIndex < srcHigh: - while lineEndIndex < srcHigh and - lex.sSource.src[lineEndIndex] notin lineEnd: - inc(lineEndIndex) + while lex.sSource.src[lineEndIndex] notin lineEnd: inc(lineEndIndex) while true: - while lineStartIndex >= 0 and - lineStartIndex < srcHigh and - lex.sSource.src[lineStartIndex] notin lineEnd: + while lineStartIndex >= 0 and lex.sSource.src[lineStartIndex] notin lineEnd: dec(lineStartIndex) - if curLine == pos.line and lineStartIndex < srcHigh: + if curLine == pos.line: inc(lineStartIndex) break - let wasLF = if lineStartIndex > srcHigh or lineStartIndex < 0: false - else: lex.sSource.src[lineStartIndex] == '\l' + let wasLF = lex.sSource.src[lineStartIndex] == '\l' lineEndIndex = lineStartIndex - if lineStartIndex > 0: - dec(lineStartIndex) - else: - break - if lineStartIndex > 0 and - lineStartIndex <= srcHigh and - lex.sSource.src[lineStartIndex] == '\c' and wasLF: + dec(lineStartIndex) + if lex.sSource.src[lineStartIndex] == '\c' and wasLF: dec(lineStartIndex) dec(lineEndIndex) dec(curLine)