marijnh/CodeMirror — pull request #1433 by JosephPecoraro (2013-04-06 10:14:57+00:00)
Title: [javascript mode] Force expecting semicolons in forspec tokenization

At CodeMirror: 1520c65

I was seeing unexpected JavaScript tokenization of:

```javascript
for (1,1,(1);;) break;
```

The lexical scope inside the for loop declaration `")"` was dropping before the for loop declaration was finished. This was because the `expect(";")` calls were allowing skipping tokens if it wasn't a semicolon. This change forces a semicolon in the fall through cases in forspec1 and forspec2. I believe this should be safe with `for in` because `for in` requires either a LeftHandSideExpression (sounds like a reference) or a var declaration, both of which CodeMirror seems to handle well (vardecl explicitly allows comma lists, and a LHSE would likely be a "variable" in this context, I couldn't break it with valid code).

This style of code can be seen in minified versions of jquery.js, which we would like to pretty print accurately.

Reduction:

```html

```

Before fix:

![Screen Shot 2013-04-06 at 2 26 30 AM](https://f.cloud.github.com/assets/11351/347140/da96f728-9ea0-11e2-93ba-75b13d2f4246.png)

After fix:

![Screen Shot 2013-04-06 at 2 28 58 AM](https://f.cloud.github.com/assets/11351/347142/e37620d0-9ea0-11e2-8782-62b51c77426d.png)