Fix newline only lines
This commit is contained in:
@@ -405,7 +405,13 @@ func highlightStreamPosition2(stream: string, position: int): string =
|
|||||||
|
|
||||||
debugEcho "insertMessageAtIndex: " & $insertMessageAtIndex
|
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 =
|
proc `$`*(x: ParserState): string =
|
||||||
&"""ParserState(
|
&"""ParserState(
|
||||||
@@ -457,14 +463,14 @@ when isMainModule:
|
|||||||
D
|
D
|
||||||
|
|
||||||
EFG"""
|
EFG"""
|
||||||
# echo test1.highlightStreamPosition2(test1.find("B"))
|
echo test1.highlightStreamPosition2(test1.find("B"))
|
||||||
# echo "=============="
|
echo "=============="
|
||||||
# echo test1.highlightStreamPosition2(test1.find("C"))
|
echo test1.highlightStreamPosition2(test1.find("C"))
|
||||||
# echo "=============="
|
echo "=============="
|
||||||
# echo test1.highlightStreamPosition2(test1.find("D"))
|
echo test1.highlightStreamPosition2(test1.find("D"))
|
||||||
|
echo "=============="
|
||||||
|
|
||||||
echo test1.highlightStreamPosition2(test1.find("\n"))
|
echo test1.highlightStreamPosition2(test1.find("\n"))
|
||||||
|
echo "=============="
|
||||||
echo test1.highlightStreamPosition2(test1.find("\n", test1.find("\n") + 1))
|
echo test1.highlightStreamPosition2(test1.find("\n", test1.find("\n") + 1))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user