File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
compiler/src/dotty/tools/repl Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -70,14 +70,12 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
70
70
* then this bug will surface, so perhaps better not?
71
71
* https://github.com/scala/bug/issues/12337
72
72
*/
73
- private [repl] def truncate (str : String ): String =
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 )) + " ..."
73
+ private [repl] def truncate (str : String ): String = {
74
+ val ncp = str.codePointCount(0 , str.length) // to not cut inside code point
75
+ if ncp > MaxStringElements && ncp > 3 then
76
+ str.substring(0 , str.offsetByCodePoints(0 , MaxStringElements - 3 )) + " ..."
79
77
else str
80
- end truncate
78
+ }
81
79
82
80
/** Return a String representation of a value we got from `classLoader()`. */
83
81
private [repl] def replStringOf (value : Object )(using Context ): String = {
You can’t perform that action at this time.
0 commit comments