-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve REPL echo and exception highlighting with pprint and fansi #24298
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
base: main
Are you sure you want to change the base?
Conversation
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
|
@hamzaremmal assigning you to make sure this doesn't clash with #24243 (I'm pretty sure it would) |
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.
Not until I get #24243 in.
|
@hamzaremmal now that #24243 has landed, shall I rebase this on top of latest main? |
|
Yes please. All the REPL PRs should be rebased. |
|
@hamzaremmal I'm getting the following error trying to run |
That is expected at the moment since |
|
Before:
After:
Rather than just rendering everything as plaintext and coloring it later, we:
toString, we do not spuriously highlight parts of them depending on the specific hex hashcodes etc.123andnew Object{ override def toString = "123" }, as the former will be colored as a literal while the latter will be whiteWe manually color exception stack traces using Fansi. This generally just looks a lot better, again without random parts of it being highlighted or not depending or whether specific regexes match class names or file names.
.getMessagein white, in case the exceptions have their own colored messages so we don't over-write their colorsFor everything else, we continue using the prior highlighting logic
Some of the logic was refactored to pass around
fansi.Strs rather thanjava.lang.Strings to make it easier to keep track of colors, but otherwise I tried to minimize the churn and keep the overall code structure unchanged