Skip to content

Commit e839d0f

Browse files
committed
improvement(repl): add in feedback when resetting REPL state
As a user I'm a big fan of getting feedback from the tools I'm working with. Without out, you have to go on assumption that what you just tried worked unless it explodes. In Scala 2 when you do a `:reset` in the REPL you get a nice message about it being reset and even some details about what exactly was reset. Following that train of thought this just adds in small note when you reset your session. Here are a couple examples which you can also see in the changed tests: ```none scala>:reset -deprecation Resetting REPL state with the following settings: -deprecation ``` ```none scala>:reset Resetting REPL state. ```
1 parent 4f3d767 commit e839d0f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,16 @@ class ReplDriver(settings: Array[String],
391391
state
392392

393393
case Reset(arg) =>
394-
resetToInitial(tokenize(arg))
394+
val tokens = tokenize(arg)
395+
396+
if tokens.nonEmpty then
397+
out.println(s"""|Resetting REPL state with the following settings:
398+
| ${tokens.mkString("\n ")}
399+
|""".stripMargin)
400+
else
401+
out.println("Resetting REPL state.")
402+
403+
resetToInitial(tokens)
395404
initialState
396405

397406
case Imports =>

compiler/test-resources/repl/reset-command

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ there were 1 deprecation warning(s); re-run with -deprecation for details
33
def f(thread: Thread): Unit
44

55
scala>:reset -deprecation
6+
Resetting REPL state with the following settings:
7+
-deprecation
68

79
scala> def f(thread: Thread) = thread.stop()
810
1 warning found
@@ -16,6 +18,7 @@ scala> def resetNoArgsStillWorks = 1
1618
def resetNoArgsStillWorks: Int
1719

1820
scala>:reset
21+
Resetting REPL state.
1922

2023
scala> resetNoArgsStillWorks
2124
-- [E006] Not Found Error: -----------------------------------------------------

0 commit comments

Comments
 (0)