-
Notifications
You must be signed in to change notification settings - Fork 378
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
Inconsistent JS hints depending on whitespace #241
Comments
The error-correcting parser is whitespace sensitive, and thus sometimes produces odd results. I have some plans on how it could be improved (with a separate brace-balancing pass), but it'd require some major work that I currently don't have the time for. |
OK, that's good to know. This issue alone is not worth "major work", I should think. |
I haven't looked at the "error-correcting parser" so this may be stupid, but could you potentially pull in a consistent beautifier (like UglifyJS 2) and normalize input formatting accordingly before handing it to the parser? That way you can make better assumptions about the structure... |
No, that does not help -- a beautifier needs to parse the code first, and if it's not syntactically valid, it can't beautify it. The problem exists in the parsing of broken syntax. |
Ahh, I see now. Knew I should have read the code first. |
Go to the Tern demo page
Reformat the CTor function with newlines:
Then, add another line to the function, with the new line properly aligned:
ctrl-space with the cursor where the
|
character is above will produce the correct results.However, if the line is not aligned with the line above (as in the example above), ctrl-space produces general results rather than results specific to CTor.
This is likely low priority, because most people align their code. However, I do wonder if there are cases in which whitespace sensitivity could actually trip up Tern.
The text was updated successfully, but these errors were encountered: