ignore trailing commas when inferring newlines - fixes #1304

This commit is contained in:
Sebastian McKenzie
2015-05-31 09:46:05 +01:00
parent 1436753e6d
commit 236086bee5
4 changed files with 7 additions and 7 deletions

View File

@@ -38,12 +38,11 @@ export default class Whitespace {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var j = 0; j < tokens.length; j++) {
// optimize for forward traversal by shifting for loop index
var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
token = tokens[i];
var token = tokens[i];
// this is the token this node starts with
if (node.start === token.start) {
@@ -62,17 +61,17 @@ export default class Whitespace {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var j = 0; j < tokens.length; j++) {
// optimize for forward traversal by shifting for loop index
var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
token = tokens[i];
var token = tokens[i];
// this is the token this node ends with
if (node.end === token.end) {
startToken = token;
endToken = tokens[i + 1];
if (endToken.type.label === ",") endToken = tokens[i + 2];
this._lastFoundIndex = i;
break;

View File

@@ -14,7 +14,6 @@ export default function (code, opts = {}) {
strictMode: opts.strictMode,
sourceType: opts.sourceType,
locations: true,
onComment: comments,
features: opts.features || {},
plugins: opts.plugins || {},
onToken: tokens,