Skip to content

Add string interpolation highlighting #24

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

Merged
merged 4 commits into from
May 14, 2019

Conversation

PanAeon
Copy link
Contributor

@PanAeon PanAeon commented May 8, 2019

My take on #11
Dark screenshot:
Dark
Light screenshot:
White

One thing I don't like is that "${variable}" and "$variable" are highlighted differently. I can change it to no highlighting so it would be more consistent.
Decided that more consistent syntax is better:

Screen Shot 2019-05-09 at 16 49 19pm

What do you think?

@torkelrogstad
Copy link

Tested locally and verified that multi line strings also work.

@olafurpg
Copy link
Contributor

Thank you for this contribution! I am super excited to enjoy this fix since the current syntax highlighting makes it really difficult to work with interpolator strings.

I just tried this locally and the quotes " for interpolator strings are colored differently from normal strings.

Screenshot 2019-05-13 at 15 26 53

I expected the color for quotes " to be colored the same like in the screenshots from @PanAeon in the PR description. I'm using the default dark theme, but I can reproduce the issue with other color themes.

const letterOrDigit = `${letter}|${digit}`
const opchar = `[!#%&*+\\-\\/:<>=?@\\\\^|~[\\p{Sm}\\p{So}]]`
const op = `${opchar}+`
const idrest = `${letter}(?:${letterOrDigit})*(?:_${op})?`
Copy link
Contributor

Choose a reason for hiding this comment

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

This one seems unused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed unused declarations

@PanAeon
Copy link
Contributor Author

PanAeon commented May 13, 2019

Good catch. I reproduced the quotes bug. It looks like I mark the text inside string as string.quoted.{double|tripple}.scala, but don't do this for the quotes.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

I can confirm the quotes are now colored correctly, thank you @PanAeon for the fix!

LGTM 👍 I am very excited to use this improvement!

Screenshot 2019-05-14 at 11 08 37

@olafurpg
Copy link
Contributor

I believe we should also consider updating the GitHub Linguist highlighting to use this improvements once merged. Code fences on github.com render string interpolators incorrectly

Screenshot 2019-05-14 at 11 12 29

iiuc, this fix could improve that well

@olafurpg olafurpg merged commit 46963ea into scala:master May 14, 2019
@olafurpg
Copy link
Contributor

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