File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
compiler/src/dotty/tools/repl Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -64,18 +64,23 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
64
64
myClassLoader
65
65
}
66
66
67
- /** Used to elide output in replStringOf.
67
+ /** Used to elide long output in replStringOf.
68
+ *
68
69
* TODO: Perhaps implement setting scala.repl.maxprintstring as in Scala 2, but
69
70
* then this bug will surface, so perhaps better not?
70
71
* https://github.com/scala/bug/issues/12337
71
72
*/
72
73
private [repl] def truncate (str : String ): String =
73
- if str.length > MaxStringElements then str.take(MaxStringElements - 3 ) + " ..."
74
+ def adjust (s : String ): String = // to not cut a Unicode character in half
75
+ if s.nonEmpty && s.last.isUnicodeIdentifierStart then s.dropRight(1 )
76
+ else s
77
+
78
+ if str.length > MaxStringElements then adjust(str.take(MaxStringElements - 3 )) + " ..."
74
79
else str
80
+ end truncate
75
81
76
82
/** Return a String representation of a value we got from `classLoader()`. */
77
83
private [repl] def replStringOf (value : Object )(using Context ): String = {
78
-
79
84
assert(myReplStringOf != null ,
80
85
" replStringOf should only be called on values creating using `classLoader()`, but `classLoader()` has not been called so far" )
81
86
truncate(myReplStringOf(value))
You can’t perform that action at this time.
0 commit comments