summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2014-08-12 12:05:21 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2014-08-12 12:05:21 +0200
commited9cca8a2660e7832613be507c4175a532e6edcb (patch)
treee9f8a8aa14b2cf7f053014034fc9df507f400da1 /src
parentbc0fc0fb90c81038dba16415ee6e733e4e054a28 (diff)
parented9dfee181e56bb83afa0598523786bee5572068 (diff)
downloadscala-ed9cca8a2660e7832613be507c4175a532e6edcb.tar.gz
scala-ed9cca8a2660e7832613be507c4175a532e6edcb.tar.bz2
scala-ed9cca8a2660e7832613be507c4175a532e6edcb.zip
Merge pull request #3902 from gourlaysama/wip/t4563
SI-4563 friendlier behavior for Ctrl+D in the REPL
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Properties.scala1
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ILoop.scala9
2 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala
index ed5fda9c3f..59fefba954 100644
--- a/src/compiler/scala/tools/nsc/Properties.scala
+++ b/src/compiler/scala/tools/nsc/Properties.scala
@@ -14,6 +14,7 @@ object Properties extends scala.util.PropertiesTrait {
// settings based on jar properties
def residentPromptString = scalaPropOrElse("resident.prompt", "\nnsc> ")
def shellPromptString = scalaPropOrElse("shell.prompt", "\nscala> ")
+ def shellInterruptedString = scalaPropOrElse("shell.interrupted", ":quit\n")
// derived values
def isEmacsShell = propOrEmpty("env.emacs") != ""
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
index ce0eadc04f..50c89f7442 100644
--- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
@@ -430,7 +430,14 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
import scala.concurrent.duration._
Await.ready(globalFuture, 60.seconds)
- (line ne null) && (command(line) match {
+ if (line eq null) {
+ // SI-4563: this means the console was properly interrupted (Ctrl+D usually)
+ // so we display the output message (which by default ends with
+ // a newline so as not to break the user's terminal)
+ if (in.interactive) out.print(Properties.shellInterruptedString)
+
+ false
+ } else (command(line) match {
case Result(false, _) => false
case Result(_, Some(line)) => addReplay(line) ; true
case _ => true