Skip to content
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

catch should not be a keyword when used in a Promise chain #1526

Closed
phortuin opened this issue Aug 15, 2018 · 2 comments · Fixed by #1527
Closed

catch should not be a keyword when used in a Promise chain #1526

phortuin opened this issue Aug 15, 2018 · 2 comments · Fixed by #1527

Comments

@phortuin
Copy link

Currently, when parsing javascript, catch will be rendered as a keyword. Since ES6, catch is also a method on the Promise prototype, which is probably best rendered as a function in Prism:

fetch('some-resource.json')
    .then(response => response.json())
    .catch(console.error)

Hopefully, there is an easy way to test for this. Thanks!

@mAAdhaTTah
Copy link
Member

I think if we highlight catch as a keyword only if it's not preceded by a dot, that would work?

@RunDevelopment
Copy link
Member

RunDevelopment commented Aug 15, 2018

In JS, catch is only used in try...catch blocks so we could say, that it will only a keyword if it's preceded by /}\s*/. (Same for finally.)
Like this, we should also be able to eliminate most false positives from identifiers and functions.

Or am I forgetting something?

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

Successfully merging a pull request may close this issue.

3 participants