js-beautify-sublime icon indicating copy to clipboard operation
js-beautify-sublime copied to clipboard

Gets confused by comments

Open robinzimmermann opened this issue 10 years ago • 3 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);
    }
};

robinzimmermann avatar Dec 17 '14 20:12 robinzimmermann

+1

bwiggs avatar Mar 13 '15 16:03 bwiggs

exx

I tried your code and it work perfectly :D. There's no confused :D

hiepnhl avatar Mar 31 '15 09:03 hiepnhl

+1

amritk avatar Jun 09 '15 23:06 amritk