Skip to content

Conversation

@lihaoyi
Copy link
Contributor

@lihaoyi lihaoyi commented Oct 29, 2025

Before:

Screenshot 2025-10-29 at 11 18 35 AM

After:

Screenshot 2025-10-29 at 11 18 36 AM

Rather than just rendering everything as plaintext and coloring it later, we:

  • Preserve the colors that PPrint applies to the pretty-printed text.
    • This means that for objects which are not handled via PPrint and go via their toString, we do not spuriously highlight parts of them depending on the specific hex hashcodes etc.
    • This also means we can distinguish between the integer 123 and new Object{ override def toString = "123" }, as the former will be colored as a literal while the latter will be white
Screenshot 2025-10-29 at 4 06 40 PM
  • We 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.

    • I kept it mostly red-and-white, to avoid the "rainbow" of noisy colors that was there before and making it obviously it's a failure. The
    • I kept the exception .getMessage in white, in case the exceptions have their own colored messages so we don't over-write their colors
  • For everything else, we continue using the prior highlighting logic

Some of the logic was refactored to pass around fansi.Strs rather than java.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

@lihaoyi lihaoyi changed the title Improve REPL output and exception highlighting with pprint and fansi Improve REPL echo and exception highlighting with pprint and fansi Oct 29, 2025
Copy link
Contributor

@Gedochao Gedochao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Gedochao
Copy link
Contributor

@hamzaremmal assigning you to make sure this doesn't clash with #24243 (I'm pretty sure it would)

Copy link
Member

@hamzaremmal hamzaremmal left a 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.

@lihaoyi
Copy link
Contributor Author

lihaoyi commented Nov 1, 2025

@hamzaremmal now that #24243 has landed, shall I rebase this on top of latest main?

@hamzaremmal
Copy link
Member

Yes please. All the REPL PRs should be rebased.

@lihaoyi
Copy link
Contributor Author

lihaoyi commented Nov 1, 2025

@hamzaremmal I'm getting the following error trying to run bin/scala clean on the latest main, which blocks manual testing of this feature.

Please bear in mind that non-ideal user experience should be expected.
If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
Error: Could not find or load main class dotty.tools.repl.Main
Caused by: java.lang.ClassNotFoundException: dotty.tools.repl.Main

@hamzaremmal
Copy link
Member

@hamzaremmal I'm getting the following error trying to run bin/scala clean on the latest main, which blocks manual testing of this feature.

Please bear in mind that non-ideal user experience should be expected.
If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
Error: Could not find or load main class dotty.tools.repl.Main
Caused by: java.lang.ClassNotFoundException: dotty.tools.repl.Main

That is expected at the moment since scala-cli doesn't have any knowledge of the new artifact scala3-repl. @Gedochao is working on releasing the next version of scala-cli that support this next week. Speaking of, I'm actually writing an email to you and Eugene about mill and sbt respectively since neither of them now work too.

@Gedochao
Copy link
Contributor

Gedochao commented Nov 4, 2025

@Gedochao is working on releasing the next version of scala-cli that support this next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants