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

Unclosed string problem #505

Closed
joesatriani opened this issue Aug 11, 2014 · 5 comments
Closed

Unclosed string problem #505

joesatriani opened this issue Aug 11, 2014 · 5 comments
Milestone

Comments

@joesatriani
Copy link

var name = 'a';
name = 'b';

Just remove second quote on 'a' and you will have weird format on 'b':

var name = 'a;
name = '
b ';
}

Even after you revise 'a back into 'a', second name assign stale in weird like below:

var name = 'a';
name = '
b ';
}

My problems getting worse when there is very much lines after incorrect string formatting.

@bitwiseman
Copy link
Member

Good report. The beautifier doesn't parse the whole file beforehand, so it doesn't know that you left a quote out until at least the end of that line.

What behavior would you like to see in this case? Should it simply not format the rest of the input? Pass it through unchanged?

What about other situations? Missing parenthesis or other delimiter?

I just want to understand your perspective.

@joesatriani
Copy link
Author

Previously I'm working with eclipse.
Eclipse is simply doesn't format the rest of the input and the one error is only for line var name = 'a; and for the second line (also the rest) is remain correct and unchanged.
I think the validation for string is it's must be in one line, I have no idea for multiples line string.

Below is java code in Eclipse with similar problem:
image

And below is js code in netbeans with similar problem:
image

@bitwiseman
Copy link
Member

Yes, those systems fully parse the whole file and report syntactic errors. The beautifier does not (see #200). Still, we should be able to figure out that the string is unterminated and limit the misformatting.

@bitwiseman bitwiseman added this to the v1.5.2 milestone Sep 11, 2014
@joesatriani
Copy link
Author

For string, if the close character is not found until end of line, it's marked as error and parsing process can continue guess the rest of stream.
At least this is what user expect.

@bitwiseman
Copy link
Member

Agree, this should be a straightforward fix.
As noted, I already made this a bug and added it to our current milestone to fix.
Thanks!

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