Skip to content

fix #11377 truncate big output in REPL #11378

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

Merged
merged 11 commits into from
Feb 24, 2021
Merged
Changes from 2 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
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/repl/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,17 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
myClassLoader
}

/** Used to elide output in replStringOf. TODO: Implement setting scala.repl.maxprintstring as in Scala 2 */
private[repl] def truncate(str: String): String =
if str.length > MaxStringElements then str.take(MaxStringElements - 3) + "..."
else str

/** Return a String representation of a value we got from `classLoader()`. */
private[repl] def replStringOf(value: Object)(using Context): String = {

assert(myReplStringOf != null,
"replStringOf should only be called on values creating using `classLoader()`, but `classLoader()` has not been called so far")
myReplStringOf(value)
truncate(myReplStringOf(value))
}

/** Load the value of the symbol using reflection.
Expand Down