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

Annotations: duplicate annotations in CSS mode #4809

Closed
BenSouchet opened this issue May 31, 2022 · 3 comments
Closed

Annotations: duplicate annotations in CSS mode #4809

BenSouchet opened this issue May 31, 2022 · 3 comments

Comments

@BenSouchet
Copy link
Contributor

Describe the bug

In CSS mode if we enter this:

h2 {
    

The newlines are mandatory to ensure the bug to occurs.

We get 2x the exact same "error" annotation (same text, row, col, rule, ...).

I currently use the 1.5.0 ace-min version available in the build repo.

Expected Behavior

Only one annotation. Not twice the same one.

Current Behavior

Currently we get twice the exact same annotation:

{row: 2, column: 0, text: "Unexpected token 'null' at line 3, col 1.", type: 'error', rule: 'Parsing Errors'}
{row: 2, column: 0, text: "Unexpected token 'null' at line 3, col 1.", type: 'error', rule: 'Parsing Errors'}

Reproduction Steps

Initialize an Ace editor with CSS mode, then enter these lines:

h2 {
    

The newlines are required.

Now if you console log the annotations of the current Editor session you will get:

{row: 2, column: 0, text: "Unexpected token 'null' at line 3, col 1.", type: 'error', rule: 'Parsing Errors'}
{row: 2, column: 0, text: "Unexpected token 'null' at line 3, col 1.", type: 'error', rule: 'Parsing Errors'}

Twice the same with the exact same line and column.

Possible Solution

No response

Additional Information/Context

No response

Ace Version

1.5.0

@BenSouchet
Copy link
Contributor Author

Additional info: I have tested on version 1.5.3 just in case, and the issue is the same.

@BenSouchet
Copy link
Contributor Author

@andrewnester I tried to investigate a bit 🙂
After a bit of time and a lot of breakpoints I understood that two annotations are registered because when verifying the CSS code in the worker-css.js:

  • There is a first SyntaxError catch in _readDeclarations() (called by _ruleset(), itself called by _stylesheet()).
  • Still in _readDeclarations() there is these lines:
else if (tt !== Tokens.RBRACE) {
    throw ex;
}
  • So the exception is forwarded and catch again by the caller _stylesheet(), this will generate the second msg.

When the exception is caught a reporter.error( is called to add an error, this is why there is two times the exact same annotation.

The questions are:

  • Why in _readDeclarations() the exception is consumed and throw to be consumed again ?
  • Why the token value is null? Since the true error is missing RBRACE.

@BenSouchet
Copy link
Contributor Author

BenSouchet commented Jun 2, 2022

I created a Pull Request ( #4816 ) to fix this wrong double error and fire the correct one. I close the issue 🙂

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

No branches or pull requests

2 participants