-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
(Swift) params
does not handled nested parens properly
#2857
Comments
No, it's because To do this right you typically need a new mode. If we had sugar for it it might look like this: { className: 'params',
begin: /\(/, end: /\)/, endsParent: true,
contains: [
{'self', endsParent: false }, // this is magic sugar that doesn't exist plus being invalid JS, lol
NUMBER, So one has to have two modes OR remove the endsParent... I'm not sure what it's intended to do. I mean I know what it's intended to do (end the
It most certainly does, I'm not sure what you're seeing. There is no special handling of line breaks anywhere though. The function is either terminated by
This is something we traditionally highlight... it's up to themes to decide what to do with it... a theme that turns it all the same color probably isn't the best choice for Swift. Our parsing is currently a tree though so it's possible for themes to style .hljs-function .hljs-params .hljs-typing {
color: #FD971F;
} I'd be open to getting into a larger discussion about this though. |
Any time we're talking visual stuff screen grabs are often nice. :-) Are types and classes the same thing in Swift? I would imagine in some languages they are different so having the context of "we're in params now" could help with knowing how to highlight identifiers, etc... |
params
does not handled nested parens properly
What are some of the more complex cases? Can I write 100 lines of code and insert an inline function as a default argument or something crazy? Also, it truly shouldn't "all be one color"... in the best case the grammar should be enhanced to add some nuance... highlight types, argument names, etc... the question is do we need the context of params to do that properly. I feel like SOME of that content should indeed be highlighted as params, no? For example here is the type of highlighting commonly seen: So for Swift perhaps only |
I'd guess not, typically we haven't supported highlighting function dispatch - though we're open to that now if it can be detected. |
…ipts (#2930) This PR improves highlighting for functions, initializers, and subscripts. This includes detailed highlighting for generic parameters as well as function parameters. To differentiate between tuple elements and function params, I've also added a mode to match tuples, whose element names should not be highlighted as params. - Fixes #2895 - Fixes #2857
In the following example:
Only the part
from corner1: (x: Double, y: Double)
is highlighted as a parameter list. I assume the grammar thinks the closing parenthesis of the tuple is the closing parenthesis of the parameter list?The grammar also doesn't support line breaks in parameter lists, so only the first line is highlighted.
I'm also wondering why the parameter list is highlighted at all? It can be really complex in Swift, so it doesn't make sense to me that it's just one color.
The text was updated successfully, but these errors were encountered: