@@ -71,13 +71,16 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
7171 // In order to figure out if it did get truncated, we invoke it twice - once with the `maxElements` that we
7272 // want to print, and once without a limit. If the first is shorter, truncation did occur.
7373 val notTruncated = stringOfMaybeTruncated(value, Int .MaxValue )
74- val maybeTruncatedByElementCount = stringOfMaybeTruncated(value, maxElements)
75- val maybeTruncated = truncate(maybeTruncatedByElementCount, maxCharacters)
76-
77- // our string representation may have been truncated by element and/or character count
78- // if so, append an info string - but only once
79- if (notTruncated.length == maybeTruncated.length) maybeTruncated
80- else s " $maybeTruncated ... large output truncated, print value to show all "
74+ if notTruncated == null then null else
75+ val maybeTruncated =
76+ val maybeTruncatedByElementCount = stringOfMaybeTruncated(value, maxElements)
77+ truncate(maybeTruncatedByElementCount, maxCharacters)
78+
79+ // our string representation may have been truncated by element and/or character count
80+ // if so, append an info string - but only once
81+ if notTruncated.length == maybeTruncated.length then maybeTruncated
82+ else s " $maybeTruncated ... large output truncated, print value to show all "
83+ end if
8184 }
8285
8386 }
@@ -95,8 +98,9 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
9598 " replStringOf should only be called on values creating using `classLoader()`, but `classLoader()` has not been called so far" )
9699 val maxPrintElements = ctx.settings.VreplMaxPrintElements .valueIn(ctx.settingsState)
97100 val maxPrintCharacters = ctx.settings.VreplMaxPrintCharacters .valueIn(ctx.settingsState)
98- val res = myReplStringOf(value, maxPrintElements, maxPrintCharacters)
99- if res == null then " null // non-null reference has null-valued toString" else res
101+ Option (value)
102+ .flatMap(v => Option (myReplStringOf(v, maxPrintElements, maxPrintCharacters)))
103+ .getOrElse(" null // non-null reference has null-valued toString" )
100104
101105 /** Load the value of the symbol using reflection.
102106 *
0 commit comments