js-beautify-sublime
js-beautify-sublime copied to clipboard
Gets confused by comments
Comments in the JavaScript code seem to cause confusion.
If I take this code:
var handleProtocolClick = function(event) {
protocol = getProtocolFromId(event.target.id);
var index = $.inArray(protocol, state.protocols);
if (index > -1) {
// If present it, remove it.
state.protocols.splice(index, 1);
} else {
state.protocols.push(protocol);
}
};
and beautify it, I get this:
var handleProtocolClick = function(event) {
protocol = getProtocolFromId(event.target.id);
var index = $.inArray(protocol, state.protocols);
if (index > -1) {
// If present it, remove it.
state.protocols.splice(index, 1);
} else {
state.protocols.push(protocol);
}
};
But if I remove the comment, it works:
var handleProtocolClick = function(event) {
protocol = getProtocolFromId(event.target.id);
var index = $.inArray(protocol, state.protocols);
if (index > -1) {
state.protocols.splice(index, 1);
} else {
state.protocols.push(protocol);
}
};
+1
I tried your code and it work perfectly :D. There's no confused :D
+1