Fix newline only lines
This commit is contained in:
@@ -405,7 +405,13 @@ func highlightStreamPosition2(stream: string, position: int): string =
|
||||
|
||||
debugEcho "insertMessageAtIndex: " & $insertMessageAtIndex
|
||||
|
||||
stream.dup(insert(&"\n{spaceChars}^{lineChars} Char at \"{escapedChar}\"\n", insertMessageAtIndex))
|
||||
let beforeNewline =
|
||||
case (startIndex, ch):
|
||||
of (-1, '\n'): "\n"
|
||||
of (_, '\n'): ""
|
||||
else: "\n"
|
||||
|
||||
stream.dup(insert(&"{beforeNewline}{spaceChars}^{lineChars} Char at \"{escapedChar}\"\n", insertMessageAtIndex))
|
||||
|
||||
proc `$`*(x: ParserState): string =
|
||||
&"""ParserState(
|
||||
@@ -457,14 +463,14 @@ when isMainModule:
|
||||
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("B"))
|
||||
echo "=============="
|
||||
echo test1.highlightStreamPosition2(test1.find("C"))
|
||||
echo "=============="
|
||||
echo test1.highlightStreamPosition2(test1.find("D"))
|
||||
echo "=============="
|
||||
echo test1.highlightStreamPosition2(test1.find("\n"))
|
||||
echo "=============="
|
||||
echo test1.highlightStreamPosition2(test1.find("\n", test1.find("\n") + 1))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user