Skip to content

Commit 9f5cc90

Browse files
committed
1 parent f57fb8e commit 9f5cc90

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,15 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
7373
myClassLoader
7474
}
7575

76-
/** Used to elide long output in replStringOf.
77-
*
78-
* TODO: Perhaps implement setting scala.repl.maxprintstring as in Scala 2, but
79-
* then this bug will surface, so perhaps better not?
80-
* https://github.com/scala/bug/issues/12337
81-
*/
76+
/** Used to elide long output in replStringOf. */
8277
private[repl] def truncate(str: String)(using ctx: Context): String =
83-
val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
78+
// FIXME introduce a new setting `-Vrepl-max-print-characters` that allows to limit truncation by character properly
79+
// see https://github.com/lampepfl/dotty/pull/16011#issuecomment-1245099657
80+
val maxPrintCharacters = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
8481
val showTruncated = " ... large output truncated, print value to show all"
8582
val ncp = str.codePointCount(0, str.length) // to not cut inside code point
86-
if ncp <= maxPrintElements then str
87-
else str.substring(0, str.offsetByCodePoints(0, maxPrintElements - 1)) + showTruncated
83+
if ncp <= maxPrintCharacters then str
84+
else str.substring(0, str.offsetByCodePoints(0, maxPrintCharacters - 1)) + showTruncated
8885

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

0 commit comments

Comments
 (0)