akalongman / sublimetext-codeformatter

Code Formatter plugin for ST2/ST3
MIT License
771 stars 131 forks source link

[JS] Improve param "preserve line break" or add a param "max_char" #35

Closed 3ffy closed 10 years ago

3ffy commented 10 years ago

Hi, when i'm using the pugin about js formatting, i got a strange behavior, whatever i try, he always put (jquery) chained events on the same line. Ex :

This

this._socket
    .on('connect', $.proxy(this.onConnect, this))
    .on('connect_failed', $.proxy(this.onConnectFailed, this))
    .on('disconnect', $.proxy(this.onDisconnect, this));

became

this._socket.on('connect', $.proxy(this.onConnect, this)).on('connect_failed', $.proxy(this.onConnectFailed, this)).on('disconnect', $.proxy(this.onDisconnect, this));

This is annoying because in my application i got a lot of chained events (ex : 30), and the formatted line took more than 5 times my width screen :/ .

3ffy commented 10 years ago

refering to http://jsbeautifier.org/ and https://github.com/einars/js-beautify, this jsbeautifier param fix the whole problem : "break_chained_methods": true

The work around seems to "only" add this param into your plugin and give it to the jsbeautifier js formater.

3ffy commented 10 years ago

I tried to make a bugfix (fork + pull request) : https://github.com/akalongman/sublimetext-codeformatter/pull/36 . Thanks about your job.