diff --git a/src/parser/parser_types.nim b/src/parser/parser_types.nim index 1161882..7b2d8f6 100644 --- a/src/parser/parser_types.nim +++ b/src/parser/parser_types.nim @@ -361,10 +361,10 @@ func highlightStreamPosition2(stream: string, position: int): string = let (lineStartPosition, lineEndPosition) = case ch: - # of '\n': - # let lineStartPosition = (position - 1).max(0) - # let lineEndPosition = (position).min(stream.len - 1) - # (lineStartPosition, lineEndPosition) + of '\n': + let lineStartPosition = (position - 1).max(0) + let lineEndPosition = (position + 1).min(stream.len - 1) + (lineStartPosition, lineEndPosition) else: (position, position) @@ -452,16 +452,22 @@ proc `$`*(x: ParserError): string = else: "ParseError" when isMainModule: - let test1 = """AB + let test1 = """ABC + +D + +EFG""" + # echo test1.highlightStreamPosition2(test1.find("B")) + # echo "==============" + # echo test1.highlightStreamPosition2(test1.find("C")) + # echo "==============" + # echo test1.highlightStreamPosition2(test1.find("D")) + + + echo test1.highlightStreamPosition2(test1.find("\n")) + echo test1.highlightStreamPosition2(test1.find("\n", test1.find("\n") + 1)) -C -D""" - echo test1.highlightStreamPosition2(test1.find("B")) - echo "==============" - echo test1.highlightStreamPosition2(test1.find("C")) - echo "==============" - echo test1.highlightStreamPosition2(test1.find("D")) # echo "\n1\n".rfind('\n', 0, 2) # block highlightStreamPosition: