tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

Function indentation has a lousy compromise #62

Closed tamzinblake closed 12 years ago

tamzinblake commented 12 years ago

js3-consistent-level-indent-inner-bracket breaks a lot of intuitively good indentation, but it is preferred by some people because of the following two cases:

  var f3 = function () {
    foo()
  }

AND

  ;(function () {
    var a = 1
  })()

Ideally, those cases should just be handled correctly.

tamzinblake commented 12 years ago

The funny thing about the fix in 29d3a21 is that you'll have to re-indent everything if you add another function after the first in a var declaration. But that's better than anyone else's current solution for that, and who does that anyway?

mbriggs commented 12 years ago

Hey thom, I am still not getting correct indentation with immediately invoking functions, although I am from single var = functions. here is my indentation


;(function(){
    foo = 1
  }())

var foo = function(){
  foo = 1
}

I don't have any js3 vars set at this point other then global externs

tamzinblake commented 12 years ago

That's at the beginning of the buffer, right?

mbriggs commented 12 years ago

Yup, that was it :D add a newline at the start of the buffer and both work. Thanks so much for this man :)

tamzinblake commented 12 years ago

new version should fix that.