| Summary: | [formatter] Regex can confuse javascript formatter | ||
|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Edward Winkelman <ewinkelman> |
| Component: | General | Assignee: | Project Inbox <jsdt.javascript-inbox> |
| Status: | NEW --- | QA Contact: | Chris Jaun <cmjaun> |
| Severity: | minor | ||
| Priority: | P3 | CC: | bruce.edge |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
NB: The regex is entered all on one line NB? (In reply to comment #2) > NB? NB means note well. As an admendum, apparently this doesn't happen in pure JS files. Only when the javascript is part of a JSP (and therefore also subject to the JSP editor) You've made sure the settings for HTML content allow for lines that long? (In reply to comment #4) > You've made sure the settings for HTML content allow for lines that long? I have word wrap set at the same for all of the editors (120 characters in this case). That particular line is too long, but it shouldn't cause the lines before and after it to start indenting and wrapping themselves. Here's another one that trips the js regex validator:
/^(|[A-Za-z0-9/+]{40})$/
Multiple markers at this line
- Syntax error, insert "}" to complete ObjectLiteral
- Syntax error on token "]", delete this token
- Syntax error on token ",", invalid (
- Syntax error on token "40", delete this token
- Syntax error, insert ")" to complete Arguments
- Missing semicolon
- Syntax error, insert "}" to complete MethodBody
|
Build Identifier: 20110615-0604 Inclusion of certain regex expressions can cause the javascript formatter to get confused, start wrapping lines and indenting unnecessarily. An example using a jQuery excerpt that performs e-mail validation: $(document).ready(function() { var emailRegEx = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.([a-z][a-z]+)|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i; $('#email').keyup(function() { if (!emailRegEx.test(('#email').value)) { alert('Bad e-mail address'); } }); }); Reproducible: Always Steps to Reproduce: 1. Enter the above regex into a javascript file 2. Press ctrl-shift-f to trigger the formatter