Skip to content

Commit 320ed99

Browse files
committed
ctx.settings.VreplMaxPrintElements.value at all use-sites
as suggested in scala#16011 (comment)
1 parent b39f1fd commit 320ed99

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import dotc.reporting.Diagnostic
2323
* `ReplDriver#resetToInitial` is called, the accompanying instance of
2424
* `Rendering` is no longer valid.
2525
*/
26-
private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
27-
maxPrintElements: Int = 1000) {
26+
private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
2827

2928
import Rendering._
3029

@@ -33,7 +32,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
3332
private var myReplStringOf: Object => String = _
3433

3534
/** Class loader used to load compiled code */
36-
private[repl] def classLoader()(using Context) =
35+
private[repl] def classLoader()(using ctx: Context) =
3736
if (myClassLoader != null && myClassLoader.root == ctx.settings.outputDir.value) myClassLoader
3837
else {
3938
val parent = Option(myClassLoader).orElse(parentClassLoader).getOrElse {
@@ -49,6 +48,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
4948
}
5049

5150
myClassLoader = new AbstractFileClassLoader(ctx.settings.outputDir.value, parent)
51+
val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
5252
myReplStringOf = {
5353
// We need to use the ScalaRunTime class coming from the scala-library
5454
// on the user classpath, and not the one available in the current
@@ -78,7 +78,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None,
7878
* then this bug will surface, so perhaps better not?
7979
* https://github.com/scala/bug/issues/12337
8080
*/
81-
private[repl] def truncate(str: String): String = {
81+
private[repl] def truncate(str: String)(using ctx: Context): String = {
82+
val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
8283
val showTruncated = " ... large output truncated, print value to show all"
8384
val ncp = str.codePointCount(0, str.length) // to not cut inside code point
8485
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)