Avoid possible divide by zero

On the off chance that in some configurations the terminal width is set
to zero, avoid an exception by returning 0 for terminal lines. It is
likely that supershell will not work well if terminal width is zero, but
that's better than a potential crash (I think the crash would be in the
progress background thread, so I'm not sure how bad it would be, but
still its good to avoid).
This commit is contained in:
Ethan Atkins 2019-09-24 16:35:03 -07:00
parent 5cfab4c9a9
commit 9c2dd05b6a
1 changed files with 1 additions and 1 deletions

View File

@ -389,7 +389,7 @@ class ConsoleAppender private[ConsoleAppender] (
out.flush()
}
private def terminalLines(width: Int): String => Int =
(progressLine: String) => (progressLine.length - 1) / width
(progressLine: String) => if (width > 0) (progressLine.length - 1) / width else 0
private def deleteConsoleLines(n: Int): Unit = {
(1 to n) foreach { _ =>
out.println(DeleteLine)