From 869df338617f2210217827c83d3ef9dc6d810e65 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 20 May 2016 18:19:08 -0700 Subject: SI-7898 Quiet REPL at startup Enable noisy modes only when interpreting user input. --- src/repl/scala/tools/nsc/interpreter/ILoop.scala | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index adaf3a5d25..4e0f60cf2b 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -908,9 +908,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) // we can get at it in generated code. intp.quietBind(NamedParam[IMain]("$intp", intp)(tagOfIMain, classTag[IMain])) - // add a help function for anyone who types "help" instead of ":help". Easily shadowed. - //addHelp() - // Auto-run code via some setting. ( replProps.replAutorunCode.option flatMap (f => File(f).safeSlurp()) @@ -938,9 +935,24 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) } case _ => } - // TODO: wait until after startup to enable obnoxious settings - def withSuppressedSettings[A](body: =>A): A = { - body + // wait until after startup to enable noisy settings + def withSuppressedSettings[A](body: => A): A = { + val ss = this.settings + import ss._ + val noisy = List(Xprint, Ytyperdebug) + val noisesome = noisy.exists(!_.isDefault) + val current = (Xprint.value, Ytyperdebug.value) + if (isReplDebug || !noisesome) body + else { + this.settings.Xprint.value = List.empty + this.settings.Ytyperdebug.value = false + try body + finally { + Xprint.value = current._1 + Ytyperdebug.value = current._2 + intp.global.printTypings = current._2 + } + } } def startup(): String = withSuppressedSettings { // starting -- cgit v1.2.3