Skip to content

Rework hl interpolator #3655

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

Closed
allanrenucci opened this issue Dec 11, 2017 · 2 comments
Closed

Rework hl interpolator #3655

allanrenucci opened this issue Dec 11, 2017 · 2 comments
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc exp:intermediate itype:enhancement

Comments

@allanrenucci
Copy link
Contributor

We are currently having issues with the hl interpolator.

After adding syntax highlighting to Showable, we now sometime leaks colors in error messages (e.g. #3614). The reason is because we sometime try to syntax highlight twice (first by calling show and then splicing the result within the hl interpolator).

I propose we change the API of the hl interpolator as follow:

def hl(args: Showable*)(implicit ctx: Context): String

A user of the interpolator will now need to be explicit when splicing Strings with the hl interpolator. It is a bit cumbersome, but will prevent re-coloring. We can provide helper function (or interpolator) to go from String to Showable.

@felixmulder WDYT?

@allanrenucci allanrenucci added area:reporting Error reporting including formatting, implicit suggestions, etc exp:intermediate itype:enhancement prio:medium labels Dec 11, 2017
@felixmulder
Copy link
Contributor

Sounds pretty good, looking forward to seeing where this will lead.

One thing that has been missing is some form of best-effort line splitting. We have the width as a compiler setting, so we should be able to reflow text. If this covers that - all the better :)

@smarter
Copy link
Member

smarter commented Mar 1, 2019

I think we should go further and get rid of thehl interpolator completely, just use em/ex which should be calling .show which should do the coloring when needed, and we can always have a regular hl method when we want to do highlighting explicitly, e.g.

em"No explicit ${hl("return")} allowed here."

smarter added a commit that referenced this issue May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc exp:intermediate itype:enhancement
Projects
None yet
Development

No branches or pull requests

4 participants