Skip to content

Commit

Permalink
fixes #239
Browse files Browse the repository at this point in the history
  • Loading branch information
trullock committed Mar 15, 2021
1 parent 24d3886 commit f4e1bec
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ function foo()
b = a
}
}
(function()
{
try
{
var a = {}
}
catch(ex) {}
})()
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@
b = a
}
}
(function() {
try {
var a = {}
}
catch(ex) {}
})()
8 changes: 7 additions & 1 deletion src/NUglify.Tests/TestData/JS/Input/Switch/PrettyPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ function foo() {
}
}


(function () {
try {
var a = {};
}
catch (ex) {
}
})();
17 changes: 9 additions & 8 deletions src/NUglify/JavaScript/Visitors/OutputVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2591,21 +2591,22 @@ public void Visit(ObjectLiteral node)
if(!(node.Parent is VariableDeclaration))
Indent();

var count = node.Properties.IfNotNull(p => p.Count);
if (count > 1)
var propertyCount = node.Properties.IfNotNull(p => p.Count);
if (propertyCount > 1)
NewLine();
else if(settings.OutputMode == OutputMode.MultipleLines)
else if(propertyCount == 1 && settings.OutputMode == OutputMode.MultipleLines)
Output(' ');

// output each key/value pair
node.Properties?.Accept(this);

Unindent();

if (count > 1)
if (propertyCount > 0)
Unindent();

if (propertyCount > 1)
NewLine();
else if (settings.OutputMode == OutputMode.MultipleLines)
Output(' ');
else if (propertyCount == 1 && settings.OutputMode == OutputMode.MultipleLines)
Output(' ');

Output('}');
MarkSegment(node, null, node.Context);
Expand Down

0 comments on commit f4e1bec

Please sign in to comment.