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) {
7070 * then this bug will surface, so perhaps better not?
7171 * https://github.com/scala/bug/issues/12337
7272 */
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 )) + " ..."
7977 else str
80- end truncate
78+ }
8179
8280 /** Return a String representation of a value we got from `classLoader()`. */
8381 private [repl] def replStringOf (value : Object )(using Context ): String = {
You can’t perform that action at this time.
0 commit comments