Skip to content

Commit 82ac916

Browse files
committed
Fix -Xprompt behavior
Previously, we also interpreted the newline as a significant input, which led to -Xprompt stopping only at every second error.
1 parent e8860ee commit 82ac916

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

compiler/src/dotty/tools/dotc/reporting/ConsoleReporter.scala

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,25 @@ class ConsoleReporter(
4141
}
4242

4343
/** Show prompt if `-Xprompt` is passed as a flag to the compiler */
44-
def displayPrompt()(implicit ctx: Context): Unit = {
45-
printMessage("\na)bort, s)tack, r)esume: ")
46-
flush()
44+
def displayPrompt(): Unit = {
45+
writer.println()
46+
writer.print("a)bort, s)tack, r)esume: ")
47+
writer.flush()
4748
if (reader != null) {
48-
val response = reader.read().asInstanceOf[Char].toLower
49-
if (response == 'a' || response == 's') {
50-
Thread.dumpStack()
51-
if (response == 'a')
52-
sys.exit(1)
49+
def loop(): Unit = reader.read match {
50+
case 'a' | 'A' =>
51+
new Throwable().printStackTrace(writer)
52+
System.exit(1)
53+
case 's' | 'S' =>
54+
new Throwable().printStackTrace(writer)
55+
writer.println()
56+
writer.flush()
57+
case 'r' | 'R' =>
58+
()
59+
case _ =>
60+
loop()
5361
}
54-
print("\n")
55-
flush()
62+
loop()
5663
}
5764
}
5865

0 commit comments

Comments
 (0)