Skip to content

Fix #133: Highlight inline as a soft keyword #138

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 2 commits into from
Sep 9, 2020

Conversation

nicolasstucki
Copy link
Contributor

If it is part of an inline if or match it is highlighted as a control flow keyword.
If it is part of a def or val definition it is highlighted as a declaration keyword.
Otherwise, it is not highlighted.

Screenshot 2020-08-21 at 19 13 18

@nicolasstucki nicolasstucki linked an issue Sep 7, 2020 that may be closed by this pull request
inline: {
patterns: [
{
match: `\\b(inline)\\b(?=(\\s+(?:${plainid}|${backQuotedId})\\s*:)|(.*(val|def|given)))`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the .* is a little bit dangerous, as it can be overly greedy in some instances, and match as long as there is a val somewhere else on the line. For instance:

inline if (n == 0) 1 else 2; val x = 2

is highlighted as:

image

Normally, the inline should be highlighted in the same color as the if. I think \s+ could work instead of .* (and we could then remove the \b as we're matching on \s+ anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rewrote it and added tests for this case

If it is part of an inline `if` or `match` it is highlighted as a control flow keyword.
If it is part of a `def` or `val` definition it is highlighted as a declaration keyword.
Otherwise, it is not highlighted.
@MaximeKjaer MaximeKjaer merged commit e2ab0ea into scala:master Sep 9, 2020
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.

inline given not highlighting inline inline in inline if should not be highlighted as a declaration
2 participants