prevent another StringIndexOutOfBoundsException in Graph.toAscii

This commit is contained in:
Johannes Rudolph 2013-07-31 15:28:10 +02:00
parent f5a6aa42b1
commit 701206b54d
1 changed files with 8 additions and 6 deletions

View File

@ -63,12 +63,14 @@ object Graph
if (s.length > maxColumn) s.slice(0, maxColumn - 2) + ".."
else s
def insertBar(s: String, at: Int): String =
s.slice(0, at) +
(s(at).toString match {
case " " => "|"
case x => x
}) +
s.slice(at + 1, s.length)
if (at < s.length)
s.slice(0, at) +
(s(at).toString match {
case " " => "|"
case x => x
}) +
s.slice(at + 1, s.length)
else s
def toAsciiLines(node: A, level: Int): Vector[String] = {
val line = limitLine((twoSpaces * level) + (if (level == 0) "" else "+-") + display(node))
val cs = Vector(children(node): _*)