Skip to content

Commit 26d1df9

Browse files
committed
ctx.settings.VreplMaxPrintElements.value at all use-sites
as suggested in scala#16011 (comment)
1 parent 12ceec1 commit 26d1df9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ import dotc.transform.ValueClasses
2424
* `ReplDriver#resetToInitial` is called, the accompanying instance of
2525
* `Rendering` is no longer valid.
2626
*/
27-
private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
28-
maxPrintElements: Int = 1000):
27+
private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
28+
// val maxPrintElements: Int = 1000
29+
// rootCtx.settings.VreplMaxPrintElements.valueIn(rootCtx.settingsState)
2930

3031
import Rendering._
3132

@@ -34,7 +35,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
3435
private var myReplStringOf: Object => String = _
3536

3637
/** Class loader used to load compiled code */
37-
private[repl] def classLoader()(using Context) =
38+
private[repl] def classLoader()(using ctx: Context) =
3839
if (myClassLoader != null && myClassLoader.root == ctx.settings.outputDir.value) myClassLoader
3940
else {
4041
val parent = Option(myClassLoader).orElse(parentClassLoader).getOrElse {
@@ -50,6 +51,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
5051
}
5152

5253
myClassLoader = new AbstractFileClassLoader(ctx.settings.outputDir.value, parent)
54+
val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
5355
myReplStringOf = {
5456
// We need to use the ScalaRunTime class coming from the scala-library
5557
// on the user classpath, and not the one available in the current
@@ -79,7 +81,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
7981
* then this bug will surface, so perhaps better not?
8082
* https://github.com/scala/bug/issues/12337
8183
*/
82-
private[repl] def truncate(str: String): String =
84+
private[repl] def truncate(str: String)(using ctx: Context): String =
85+
val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
8386
val showTruncated = " ... large output truncated, print value to show all"
8487
val ncp = str.codePointCount(0, str.length) // to not cut inside code point
8588
if ncp <= maxPrintElements then str

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ class ReplDriver(settings: Array[String],
113113
.setSetting(rootCtx.settings.outputDir, new VirtualDirectory("<REPL compilation output>"))
114114

115115
compiler = new ReplCompiler
116-
rendering = new Rendering(
117-
classLoader,
118-
maxPrintElements = rootCtx.settings.VreplMaxPrintElements.valueIn(rootCtx.settingsState)
119-
)
116+
rendering = new Rendering(classLoader)
120117
}
121118

122119
private var rootCtx: Context = _

0 commit comments

Comments
 (0)