mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-26 22:20:56 +00:00
handle bitwise ~ operator
This commit is contained in:
parent
60228b35c4
commit
e77f74b140
@ -1284,7 +1284,7 @@ Beautifier.prototype.handle_operator = function(current_token) {
|
||||
|
||||
// http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
|
||||
// if there is a newline between -- or ++ and anything else we should preserve it.
|
||||
if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
|
||||
if (current_token.newlines && (current_token.text === '--' || current_token.text === '++' || current_token.text === '~')) {
|
||||
this.print_newline(false, true);
|
||||
}
|
||||
|
||||
|
@ -1439,7 +1439,9 @@ class Beautifier:
|
||||
# if there is a newline between -- or ++ and anything else we
|
||||
# should preserve it.
|
||||
if current_token.newlines and (
|
||||
current_token.text == "--" or current_token.text == "++"
|
||||
current_token.text == "--"
|
||||
or current_token.text == "++"
|
||||
or current_token.text == "~"
|
||||
):
|
||||
self.print_newline(preserve_statement_flags=True)
|
||||
|
||||
|
@ -5436,7 +5436,13 @@ exports.test_data = {
|
||||
{ unchanged: 'if (1 + foo() && bar(baz()) / 2) one();\ntwo();\nthree();' },
|
||||
|
||||
{ input: 'var a=1,b={bang:2},c=3;', output: 'var a = 1,\n b = {\n bang: 2\n },\n c = 3;' },
|
||||
{ input: 'var a={bing:1},b=2,c=3;', output: 'var a = {\n bing: 1\n },\n b = 2,\n c = 3;' }
|
||||
{ input: 'var a={bing:1},b=2,c=3;', output: 'var a = {\n bing: 1\n },\n b = 2,\n c = 3;' },
|
||||
|
||||
{
|
||||
comment: 'Issue #1896: Handle newlines with bitwise ~ operator',
|
||||
input: 'if (foo) {\nvar bar = 1;\n~bar ? 0 : 1\n }',
|
||||
output: 'if (foo) {\n var bar = 1;\n ~bar ? 0 : 1\n}'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user