Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement(repl): add in feedback when resetting REPL state #14521

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,16 @@ class ReplDriver(settings: Array[String],
state

case Reset(arg) =>
resetToInitial(tokenize(arg))
val tokens = tokenize(arg)

if tokens.nonEmpty then
out.println(s"""|Resetting REPL state with the following settings:
| ${tokens.mkString("\n ")}
|""".stripMargin)
else
out.println("Resetting REPL state.")

resetToInitial(tokens)
initialState

case Imports =>
Expand Down
3 changes: 3 additions & 0 deletions compiler/test-resources/repl/reset-command
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ there were 1 deprecation warning(s); re-run with -deprecation for details
def f(thread: Thread): Unit

scala>:reset -deprecation
Resetting REPL state with the following settings:
-deprecation

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

scala>:reset
Resetting REPL state.

scala> resetNoArgsStillWorks
-- [E006] Not Found Error: -----------------------------------------------------
Expand Down