Incorrect indent bug
rmuratov opened this issue · comments
Ramil Muratov commented
Here is code I want to convert using http://js2.coffee/:
function someFunc(data, n) {
var localSum = 0;
for (var i = data.length - 1; i >= n; i--) {
for (var j = i; j > i - n; j--) {
localSum += data[j];
}
}
}
It produces:
someFunc = (data, n) ->
localSum = 0
i = data.length - 1
while i >= n
j = i
while j > i - n
localSum += data[j]
j--
i--
return
Please, take a look at the line 5 of result - indent incorrect. Back to javascript
there are 2 same level while
instead of nested:
while (i >= n) {
j = i;
}
while (j > i - n) {
localSum += data[j];
j--;
}
So j = i
should be on the same level as second while
:
while i >= n
j = i
while j > i - n
Marc Went commented
It is because enter adds spaces, whilst you are probably are working with tabs
Ramil Muratov commented
@Dunky13 I am not sure I understand what are you talking about. Ok, change tabs to spaces, spaces to tabs in input - the same result.
Philipp A. commented
@Dunky13 yeah, try pasting things in before you assume stuff, it’s like 5 seconds of work 😉
Ramil Muratov commented
Fixed as I see.