Skip to content

Commit 63d1bcc

Browse files
committed
Print new line after command as well
1 parent 3e2af77 commit 63d1bcc

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,12 @@ class ReplDriver(settings: Array[String],
197197
private def extractImports(trees: List[untpd.Tree]): List[untpd.Import] =
198198
trees.collect { case imp: untpd.Import => imp }
199199

200-
private def interpret(res: ParseResult)(implicit state: State): State =
201-
res match {
200+
private def interpret(res: ParseResult)(implicit state: State): State = {
201+
val newState = res match {
202202
case parsed: Parsed if parsed.trees.nonEmpty =>
203-
val newState = compile(parsed)
203+
compile(parsed)
204204
.withHistory(parsed.sourceCode :: state.history)
205205
.newRun(compiler, rootCtx)
206-
out.println() // Prints newline after commands, also fixes #1369
207-
newState
208206

209207
case SyntaxErrors(src, errs, _) =>
210208
displayErrors(errs)
@@ -218,6 +216,9 @@ class ReplDriver(settings: Array[String],
218216
case _ => // new line, empty tree
219217
state
220218
}
219+
out.println()
220+
newState
221+
}
221222

222223
/** Compile `parsed` trees and evolve `state` in accordance */
223224
protected[this] final def compile(parsed: Parsed)(implicit state: State): State = {

compiler/test-resources/repl/i1369

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
scala> print("foo")
2+
foo
3+
scala> "Hello"
4+
val res0: String = Hello

0 commit comments

Comments
 (0)