New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REPL: improve handling of non-printable characters (to prevent messing up terminal) #9451
Conversation
This comment has been minimized.
This comment has been minimized.
src/repl-frontend/scala/tools/nsc/interpreter/shell/ILoop.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on paper, but it's not easy to follow the change. Could you outline/describe the change some more, please?
The update takes Dale's suggestion to show test output per line, which is not as pretty, but is much easier to scan. The weird aspect is that the line endings are implicit and not shown in the hex dump. NBD. Improved comments about the pattern. Also push the alternative |
@som-snytt mind squashing into fewer commits? then let's |
@som-snytt ping. (if you're busy this week, let me know and I'll take care of it.) |
d25809a
to
1236e79
Compare
This comment has been minimized.
This comment has been minimized.
This seems a bit too eager... 2.13.4: scala> "\uCAFE caffè"
val res0: String = 쫾 caffè 2.13.5 scala> "\uCAFE caffè"
val res0: String = ? caff? |
US-ASCII FTW. "POSIX character classes (US-ASCII only)". |
// group 1 is the CSI command letter, where 'm' is color rendition | ||
// group 2 is a sequence of chars to be rendered as `?`: anything non-printable and not some space char | ||
// additional groups are introduced by linePattern but not used | ||
private lazy val cleaner = raw"$csi|([^\p{Print}\p{Space}]+)|$linePattern".r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
([\p{Cntrl}&&[^\p{Space}]]+)
for group 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
So colors can come through unscathed.
Fixes scala/bug#12276
cf aafcc10
REPL strips its wrapper identifiers from output, and also tries to suppress output that might mess up the terminal.
This commit simplifies the heuristic on "what to pass" to a regex for the alternatives: control sequences for color output, non-printable chars which are replaced by
?
, and the existing pattern for wrapper names.