Skip to content

Commit 26242a5

Browse files
committed
fix #11377 truncate big output in REPL
1 parent a7cb965 commit 26242a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
6464
myClassLoader
6565
}
6666

67+
/** Used to elide output in replStringOf. TODO: Implement setting scala.repl.maxprintstring as in Scala 2 */
68+
private[repl] def truncate(str: String): String =
69+
if str.length > MaxStringElements then (str take MaxStringElements - 3) + "..."
70+
else str
71+
6772
/** Return a String representation of a value we got from `classLoader()`. */
6873
private[repl] def replStringOf(value: Object)(using Context): String = {
74+
6975
assert(myReplStringOf != null,
7076
"replStringOf should only be called on values creating using `classLoader()`, but `classLoader()` has not been called so far")
71-
myReplStringOf(value)
77+
truncate(myReplStringOf(value))
7278
}
7379

7480
/** Load the value of the symbol using reflection.

0 commit comments

Comments
 (0)