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

JavaScript multiline argument destructuring highlight with successive block comment edge case #2469

Closed
stevenvachon opened this issue Oct 31, 2018 · 3 comments

Comments

@stevenvachon
Copy link

stevenvachon commented Oct 31, 2018

With the function arguments destructured into multiple lines, successive texts are incorrectly coloured, such as strings and code following an instance of /* within a string:
issue1

With the line of the string containing /* commented out, other strings are still incorrectly coloured:
issue2

Converting the arguments destructuring to a single line prevents the issues:
issue3

Example text:

module.exports = ({
    LOG_ERROR,
    production,
    set
}) => set({
    browsers: ['ChromeHeadless'],
    frameworks: ['source-map-support', 'jasmine-query', 'jasmine'],
    files: [
        ...legacyVendors,
        ...testHelpers,
        `${src}/cc@(App|User)/**/*.spec.js`,
        `${src}/cc@(App|user)/cc@(App|User).js`
    ],

    logLevel: LOG_ERROR,

    /*proxies: {
        '/img/': 'http://localhost:9876/img/'
    },*/
  • Operating system and version:
    • Mac OS 10.14
  • Monitor:
    • Resolution 1920x1200
  • Sublime Text:
    • Build 3180
@Thom1729
Copy link

This issue pertains to a default package, not to the core, so it should be reported here: https://github.com/sublimehq/Packages/issues.

The problem seems to start at the =>. In the third example you give, it is colored yellow, but in the first two it is left white. This should not happen, and it is surely the cause of the subsequent problems.

It is known that Sublime cannot reliably determine whether ( begins a parenthesized expression or an arrow function argument list. (This is a fundamental engine limitation, not a fixable bug in the syntax definition. See #2241 for more information.) Given this limitation, the syntax tries to guess which it is, assuming a parenthesized expression if it can't tell for sure. If it guesses wrong, the argument list may be highlighted incorrectly, but the syntax should recover if it sees => after the closing paren. For some reason, this is not happening in your example.

I could not reproduce the issue with the latest master branch, but master is ahead of the current dev build. It would help if you could post a self-contained example in text form.

@stevenvachon
Copy link
Author

stevenvachon commented Oct 31, 2018

Should I move this to the packages repo, or leave it open here as you've described it to be an engine limitation?

As requested, the example text has been added to the original comment.

@Thom1729
Copy link

The bug is that the => fallback isn't working as expected. That should go to the packages repo.

FYI, I've verified the bug in 3173 (3180 uses the same packages), and I can confirm that it's fixed in master. I could not immediately tell which PR fixed it.

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

No branches or pull requests

3 participants