From eec347e2dd7e037c30f1578d4dbb9943ea3548f2 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sat, 19 May 2012 18:20:19 -0400 Subject: [PATCH] ensure enableEcho called after jline.Terminal.getTerminal. fixes #460 --- util/complete/LineReader.scala | 5 +++-- util/log/ConsoleLogger.scala | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/util/complete/LineReader.scala b/util/complete/LineReader.scala index a48e4c141..1318061af 100644 --- a/util/complete/LineReader.scala +++ b/util/complete/LineReader.scala @@ -53,8 +53,9 @@ abstract class JLine extends LineReader } private object JLine { - def terminal = jline.Terminal.getTerminal - def resetTerminal() = withTerminal { _ => jline.Terminal.resetTerminal } + // When calling this, ensure that enableEcho has been or will be called. + // getTerminal will initialize the terminal to disable echo. + private def terminal = jline.Terminal.getTerminal private def withTerminal[T](f: jline.Terminal => T): T = synchronized { diff --git a/util/log/ConsoleLogger.scala b/util/log/ConsoleLogger.scala index a453b3b8a..ad626336f 100644 --- a/util/log/ConsoleLogger.scala +++ b/util/log/ConsoleLogger.scala @@ -35,8 +35,13 @@ object ConsoleLogger } private[this] def ansiSupported = - try { jline.Terminal.getTerminal.isANSISupported } - catch { case e: Exception => !isWindows } + try { + val terminal = jline.Terminal.getTerminal + terminal.enableEcho() // #460 + terminal.isANSISupported + } catch { + case e: Exception => !isWindows + } private[this] def os = System.getProperty("os.name") private[this] def isWindows = os.toLowerCase.indexOf("windows") >= 0