121 Commits

Author SHA1 Message Date
VittGam
2bf466493c Added tests for the decode_characters option in the JavaScript test file. 2012-06-24 23:26:29 +02:00
Einar Lielmanis
3f717d38a1 Minor improvement for actionscript 2012-05-18 10:03:40 +03:00
Einar Lielmanis
b1e925c232 Some support for actionscript's import foo.* 2012-05-17 11:17:49 +03:00
Einar Lielmanis
f89a4628c9 Fix for "preserve whitespace" in comments
This got squished:

    // a
    // b

    // c
    // d
2012-05-17 10:54:43 +03:00
Einar Lielmanis
687c8d2308 Fix #112, invalid indentation for object property "default" 2012-05-10 12:59:10 +03:00
Einar Lielmanis
59dd46f96c Fix #104, regex detection in case 2012-03-07 13:51:13 +02:00
Einar Lielmanis
9b2f4f24f6 Implement for-expr and cond-expr modes, fix #103 2012-03-05 13:29:13 +02:00
Einar Lielmanis
5faaaae13c Fix #100, borked throw {} with brace-style=expand 2012-03-04 23:31:22 +02:00
Einar Lielmanis
068ec1701a Treat HTML comments better, fixes #99 2012-03-02 17:31:44 +02:00
Einar Lielmanis
8956e2a3d9 Fix #43
if (x) {
        // ...
    }
    (function() {
        // ...
        setTimeout(arguments.callee, 5);
    })();

=>

    ...
    }(function() {
    ...
2012-02-29 19:45:02 +02:00
Einar Lielmanis
23fd0b7c0f Add support for getters and setters 2012-02-09 18:17:09 +02:00
Einar Lielmanis
dc122f4934 Fix repeated string handling
"foo"
   "bar"

   got smashed together to

   "foo""bar"
2012-02-09 13:13:07 +02:00
Einar Lielmanis
15968ac5da Never add just a space after comment
This code got borked:

    if (foo) // comment
    {
        bar;
    }

to

    if (foo) // comment {
        bar;
    }
2012-01-28 23:19:58 +02:00
Einar Lielmanis
e6b4fd15bc Regexp fix
if (something) {}
else /regexp/.zzz

the regex was not detected as a regexp.
2012-01-25 21:32:18 +02:00
Einar Lielmanis
00b1ee0bd2 @thron7: improve block comment indentation
Fixes #84
2012-01-19 06:39:45 +02:00
Einar Lielmanis
dc8c231045 Update tests
An option was renamed to "space_before_conditional", but tests weren't
updated.
2012-01-02 19:24:27 +02:00
Einar Lielmanis
cdee74c43f Changes by Stan <stasson@orc.ru>
- new styling option expand-strict which always puts braces into new
  lines. It can break the scripts badly, though, so it is not exposed in
  index.html;

- option to add - or not add - a space after operator,

- much improved comment handling.
2012-01-02 19:19:37 +02:00
Einar Lielmanis
43fbe441bb Try not to break foreign markup identifiers
Leave php and jsp crap alone, without this <% usually would get
transformed to "< %", being treated as two separate operators.
2011-10-07 13:42:18 +03:00
Einar Lielmanis
07f45ee263 Fix python crash in an empty javadoc line 2011-10-06 00:11:35 +03:00
Einar Lielmanis
2229fed8f1 var-lines always indent to specified indentation
Previously, var lines were indented to 4 spaces always,
even if the indent size = 8. There's not much reason for doing that.
2011-08-03 10:41:01 +03:00
Einar Lielmanis
6059bf3e21 Removed indent_level option
Now the beautfier adjusts the base level of the code by the first line.
This means that you can now very easily use the beautifier together with
your the editor, and the indentation level will stay as is:

  ...
  case 'foo':
      if (bar == baz) { blarp(); }
      break;
  case 'oof':
  ...

  if you pass only the "if" line, with e.g ":!jsbeautify -" in vim, it
  won't mess up the depth, and the code will be:

  ...
  case 'foo':
      if (bar == baz) {
          blarp();
      }
      break;
  case 'oof':
  ...
2011-07-15 17:23:22 +03:00
Einar Lielmanis
0e3bbb7abb Fix #45, wrong behavior with indent_level > 0
The starting spaces were always trimmed.
2011-06-12 20:35:01 +03:00
Einar Lielmanis
72016ffb16 Add my makefile and cli-spidermonkey-tester
...just so they don't get lost.
2011-06-12 20:30:32 +03:00
Einar Lielmanis
2502468acb Improve proper-block comment detection
Always detect this style comments, and reindent
them as required.

    /*
     * ......
     * .......
     *
     */

Until now, this was done only for javadoc-ish comments
starting with /**
2011-06-12 15:26:32 +03:00
Einar Lielmanis
480b2f537d keep_array_indentation could break the script
github #49, as reported by fmate14:

var a = [
    // item 1:
    {
        foo: 'bar'
    },
    // item 2:
    {
        pig: 'hug'
    }
];

to this:

var a = [
    // item 1: {
    foo: 'bar'
},
    // item 2: {
    pig: 'hug'
}
];
2011-06-11 03:37:04 +03:00
Einar Lielmanis
5862253154 Fix var x = function indentation bug
var a = function(){
        func1()
    }
    var b = function(){
        func2()
    }

got indented to

    var a = function(){
            func1()
        }
        var b = function(){
            func2()
        }

now it is

    var a = function(){
            func1()
        }
    var b = function(){
            func2()
        }

I'm not sure I'm thrilled with this indentation style, but it looks
MUCH prettier for multiple functions:

    var a = function() {
            func1()
        },
        b = function() {
            func2()
        }
2011-04-20 13:55:47 +03:00
Einar Lielmanis
1f7fd12a85 Increase first function indentation in var-line
As reported by Kambfhase:

Input/result:

    var a = function () {
        return null;
    },
        b = false;

Expected:
    var a = function () {
            return null;
        },
        b = false;

If the function is not the first value though, the indentation is
correct.
2011-04-19 22:23:54 +03:00
Einar Lielmanis
8a3baaa3c8 Inserts space in typeof (...) when jslint_happy
a = typeof (x)

jslint_happy = false:

  a = typeof(x)

jslint_happy:

  a = typeof (x)
2011-04-19 22:12:01 +03:00
Einar Lielmanis
0ef2a0d97c Change parameter space_after... -> jslint_happy
beautify.js still supports the old option, nothing should change for you
in case you use that. For now.
2011-04-19 22:10:18 +03:00
Einar Lielmanis
6f474087d0 Fix for 'a =\nb' not getting glued together 2011-04-09 16:17:05 +03:00
Einar Lielmanis
225b592bc8 Fix "new function" splitting between lines 2011-04-09 14:54:59 +03:00
Einar Lielmanis
8a3123ab9f Fix rare-ish bug with OBJECT mode 2011-03-31 07:06:13 +03:00
Einar Lielmanis
b80ca146e2 Fix python typo
Minor beautifying error creeped in, resulting in python version

    function foo() { bar(); } xxxx

transforming to

    function foo() {
        bar();
    } xxxx

(Only python version was affected)
2011-03-31 06:52:07 +03:00
Einar Lielmanis
e57fd547fd fix for "else break"
else break / else return got split to two separate lines.

Also, make javascript use same tests as python: I did a minor cleanup
while writing the python version.
2011-03-31 06:43:47 +03:00
Einar Lielmanis
246b03a4c9 Fix for single else
Input:

    if (foo)
        bar();
    else
        baz();

Was:

    if (foo) bar();
    else
    baz();

Is:

    if (foo) bar();
    else baz();
2011-03-23 22:22:54 +02:00
Einar Lielmanis
a123ba486b Oops, the patch accidentally the previous commit 2011-03-23 06:16:18 +02:00
Einar Lielmanis
0d22b9f9fc Alternate brace style patch by Chris J. Shull 2011-03-23 06:07:38 +02:00
Einar Lielmanis
d899f6146d Fix some braces-on-own-line uglinesses
var foo = {}

got destroyed to

  var foo =
  {
  }

braces-on-own-line is quite poorly tested, some regressions are
possible.
2011-03-21 21:00:23 +02:00
Einar Lielmanis
098cdbe972 Improve next token behaviour after shebang 2011-02-08 22:29:16 +02:00
Einar Lielmanis
395cc1de45 Do not mess up shebangs 2011-02-08 22:22:58 +02:00
Einar Lielmanis
16c1f228ac Better format objects in arrays
Was:

    var o = [{
        fu: 'bar'
    },
    {
        bar: 'fu'
    }];

Is:

    var o = [{
        fu: 'bar'
    }, {
        bar: 'fu'
    }];
2011-01-31 22:20:50 +02:00
Einar Lielmanis
39ed891f20 Fix for twiggling newline when !preserve_newlines
function foo() {
    return 1;
}
function bar() {
    return 2;
}

returned with empty line between functions on first run, and removed on
the next run.
2011-01-10 08:56:49 +02:00
Einar Lielmanis
4269a42194 Merge branches 'frontpage', 'returndot' and 'lineglue' 2010-12-31 11:09:34 +02:00
Einar Lielmanis
670933fe73 Fix for broken return .5
Input:

    return .5

Was:

    return.5

Is:

    return .5
2010-12-31 11:08:23 +02:00
Einar Lielmanis
03262bc17c Fix for merged line after "else" statement
For semicolon-less javascript, the next line after "else" statement
could get glued to the one before due to ignored newline.

Fix that by resetting flags.if_line to false after "else" word has been
found and processed, so that it could pick up the original newlines.

Input:

    if (foo) bar()
    else baz()
    do_something()

Was:

    if (foo) bar()
    else baz() do_something()

Now:

    if (foo) bar()
    else baz()
    do_something()
2010-12-31 10:29:04 +02:00
Einar Lielmanis
b4991387a3 Fix semicolon-less "if" collapsing bug
if (a) b()
c()
d()

got collapsed to

if (a) b() c() d()
2010-12-12 21:54:52 +02:00
Einar Lielmanis
9f8e253bca Fix an ugly regression with division operator
(a) / a was borked by a regexp-fixing commit and wasn't caught by the
tests.

Also, slightly harden the second test in bt().
2010-12-12 21:44:50 +02:00
Einar Lielmanis
239db58cd3 Properly reformat if / else
Fixes issue #30 that else/catch/finally doesn't get pulled to the previous line:

if (foo)
{
    bar();
}
else
{
    baz();
}

got reformatted to:

if (foo) {
    bar();
}
else { // sic!
    baz
}
2010-12-11 09:54:23 +02:00
Einar Lielmanis
1b26617e69 Fix some regexp detection issues
As reported by PING, the parser broke on:
variable = //comment
/regex/

Not entirely sure if the commit won't break on some weird division
cases. But, then I'll fix that, tee-hee.
2010-12-11 09:37:39 +02:00
Einar Lielmanis
70d721a67e Update the failed test 2010-12-09 08:40:15 +02:00